Skip to content

Commit 97d72e9

Browse files
authored
Merge pull request #3403 from NativeScript/pete/nsconfig-app-folder-patch1
fix(prepare): disregard app_resources's dir name when preparing in platforms/
2 parents d27e80c + 6f94b78 commit 97d72e9

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

lib/services/app-files-updater.ts

+6-6
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

+2-2
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

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ 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+
6667
if (this.$fs.exists(appResourcesDirectoryPath)) {
6768
platformData.platformProjectService.prepareAppResources(appResourcesDirectoryPath, projectData);
6869
const appResourcesDestination = platformData.platformProjectService.getAppResourcesDestinationDirectoryPath(projectData);

test/app-files-updates.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require("should");
77
function createTestInjector(): IInjector {
88
const testInjector = new yok.Yok();
99

10-
testInjector.register("projectData", { appResourcesDirectoryPath: "App_Resources"});
10+
testInjector.register("projectData", { appResourcesDirectoryPath: "App_Resources" });
1111

1212
return testInjector;
1313
}
@@ -71,7 +71,7 @@ describe("App files copy", () => {
7171

7272
it("copies all app files but app_resources when not bundling", () => {
7373
const updater = new CopyAppFilesUpdater([
74-
"file1", "dir1/file2", "App_Resources/Android/blah.png"
74+
"file1", "dir1/file2"
7575
], { bundle: false });
7676
updater.copy();
7777
assert.deepEqual(["file1", "dir1/file2"], updater.copiedDestinationItems);

0 commit comments

Comments
 (0)