Skip to content

Commit d7b244a

Browse files
committed
fix(prepare): preserve app_resources dir name despite original
app_resources dir path. This should align the names in platforms/android across the board and prevent having to do additional checks which could report false positives for the presence of app_resources when the name of the directory is too generic.
1 parent c640f95 commit d7b244a

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

lib/services/app-files-updater.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ export class AppFilesUpdater {
1313

1414
public updateApp(updateAppOptions: IUpdateAppOptions, projectData: IProjectData): void {
1515
this.cleanDestinationApp(updateAppOptions);
16-
const sourceFiles = updateAppOptions.filesToSync || this.resolveAppSourceFiles(projectData);
16+
let sourceFiles = updateAppOptions.filesToSync || this.resolveAppSourceFiles(projectData);
17+
18+
// exclude the app_resources directory from being enumerated
19+
// for copying if it is present in the application sources dir
20+
const appResourcesPathNormalized = path.normalize(projectData.appResourcesDirectoryPath + "\\");
21+
sourceFiles = sourceFiles.filter(dirName => !path.normalize(dirName).startsWith(appResourcesPathNormalized));
1722

1823
updateAppOptions.beforeCopyAction(sourceFiles);
1924
this.copyAppSourceFiles(sourceFiles);
@@ -76,11 +81,6 @@ export class AppFilesUpdater {
7681
constants.LIVESYNC_EXCLUDED_FILE_PATTERNS.forEach(pattern => sourceFiles = sourceFiles.filter(file => !minimatch(file, pattern, { nocase: true })));
7782
}
7883

79-
// exclude the app_resources directory from being enumerated
80-
// for copying if it is present in the application sources dir
81-
const appResourcesPathNormalized = path.normalize(projectData.appResourcesDirectoryPath);
82-
sourceFiles = sourceFiles.filter(dirName => !path.normalize(dirName).startsWith(appResourcesPathNormalized));
83-
8484
return sourceFiles;
8585
}
8686

lib/services/prepare-platform-js-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class PreparePlatformJSService extends PreparePlatformService implements
4242
if (config.changesInfo && !config.changesInfo.changesRequirePrepare) {
4343
// remove the App_Resources folder from the app/assets as here we're applying other files changes.
4444
const appDestinationDirectoryPath = path.join(config.platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);
45-
const appResourcesDirectoryPath = path.join(appDestinationDirectoryPath, constants.APP_RESOURCES_FOLDER_NAME);
45+
const appResourcesDirectoryPath = path.join(appDestinationDirectoryPath, path.basename(config.projectData.appResourcesDirectoryPath));
4646
if (this.$fs.exists(appResourcesDirectoryPath)) {
4747
this.$fs.deleteDirectory(appResourcesDirectoryPath);
4848
}
@@ -107,7 +107,7 @@ export class PreparePlatformJSService extends PreparePlatformService implements
107107
const appDestinationDirectoryPath = path.join(config.platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);
108108
const appResourcesSourcePath = config.projectData.appResourcesDirectoryPath;
109109

110-
shell.cp("-Rf", appResourcesSourcePath, appDestinationDirectoryPath);
110+
shell.cp("-Rf", appResourcesSourcePath, path.join(appDestinationDirectoryPath, constants.APP_RESOURCES_FOLDER_NAME));
111111
}
112112
}
113113

lib/services/prepare-platform-native-service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ export class PreparePlatformNativeService extends PreparePlatformService impleme
6363
private copyAppResources(platformData: IPlatformData, projectData: IProjectData): void {
6464
const appDestinationDirectoryPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);
6565
const appResourcesDirectoryPath = path.join(appDestinationDirectoryPath, constants.APP_RESOURCES_FOLDER_NAME);
66+
const appResourcesSourceDirectoryPath = projectData.appResourcesDirectoryPath;
67+
6668
if (this.$fs.exists(appResourcesDirectoryPath)) {
6769
platformData.platformProjectService.prepareAppResources(appResourcesDirectoryPath, projectData);
6870
const appResourcesDestination = platformData.platformProjectService.getAppResourcesDestinationDirectoryPath(projectData);
6971
this.$fs.ensureDirectoryExists(appResourcesDestination);
70-
shell.cp("-Rf", path.join(appResourcesDirectoryPath, platformData.normalizedPlatformName, "*"), appResourcesDestination);
72+
shell.cp("-Rf", path.join(appResourcesSourceDirectoryPath, platformData.normalizedPlatformName, "*"), appResourcesDestination);
7173
this.$fs.deleteDirectory(appResourcesDirectoryPath);
7274
}
7375
}

0 commit comments

Comments
 (0)