diff --git a/lib/definitions/project.d.ts b/lib/definitions/project.d.ts index fce8b05537..3ac9337349 100644 --- a/lib/definitions/project.d.ts +++ b/lib/definitions/project.d.ts @@ -28,6 +28,7 @@ interface IPlatformProjectService { afterCreateProject(projectRoot: string): IFuture; buildProject(projectRoot: string): IFuture; prepareProject(): IFuture; + prepareAppResources(appResourcesDirectoryPath: string): IFuture; isPlatformPrepared(projectRoot: string): IFuture; addLibrary(platformData: IPlatformData, libraryPath: string): IFuture; canUpdatePlatform(currentVersion: string, newVersion: string): IFuture; diff --git a/lib/services/android-project-service.ts b/lib/services/android-project-service.ts index 6d4da5f874..1561015c85 100644 --- a/lib/services/android-project-service.ts +++ b/lib/services/android-project-service.ts @@ -181,6 +181,16 @@ class AndroidProjectService implements IPlatformProjectService { public isPlatformPrepared(projectRoot: string): IFuture { return this.$fs.exists(path.join(projectRoot, "assets", constants.APP_FOLDER_NAME)); } + + public prepareAppResources(appResourcesDirectoryPath: string): IFuture { + return (() => { + let resourcesDirPath = path.join(appResourcesDirectoryPath, this.platformData.normalizedPlatformName); + let resourcesDirs = this.$fs.readDirectory(resourcesDirPath).wait(); + _.each(resourcesDirs, resourceDir => { + this.$fs.deleteDirectory(path.join(this.platformData.appResourcesDestinationDirectoryPath, resourceDir)).wait(); + }); + }).future()(); + } private parseProjectProperties(projDir: string, destDir: string): void { let projProp = path.join(projDir, "project.properties"); diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index bed5677ffb..810244d4c0 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -254,6 +254,10 @@ class IOSProjectService implements IPlatformProjectService { }).future()(); } + public prepareAppResources(appResourcesDirectoryPath: string): IFuture { + return this.$fs.deleteDirectory(this.platformData.appResourcesDestinationDirectoryPath); + } + private replace(name: string): string { if(_.startsWith(name, '"')) { name = name.substr(1, name.length-2); diff --git a/lib/services/platform-service.ts b/lib/services/platform-service.ts index c40f96a3b2..ab56fb48f3 100644 --- a/lib/services/platform-service.ts +++ b/lib/services/platform-service.ts @@ -158,10 +158,10 @@ export class PlatformService implements IPlatformService { shell.cp("-R", appSourceDirectoryPath, platformData.appDestinationDirectoryPath); // Copy App_Resources to project root folder - this.$fs.ensureDirectoryExists(platformData.appResourcesDestinationDirectoryPath).wait(); // Should be deleted var appResourcesDirectoryPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME, constants.APP_RESOURCES_FOLDER_NAME); + this.$fs.ensureDirectoryExists(platformData.appResourcesDestinationDirectoryPath).wait(); if (this.$fs.exists(appResourcesDirectoryPath).wait()) { - this.$fs.deleteDirectory(platformData.appResourcesDestinationDirectoryPath).wait(); // Respect removed files + platformData.platformProjectService.prepareAppResources(appResourcesDirectoryPath).wait(); shell.cp("-R", path.join(appResourcesDirectoryPath, platformData.normalizedPlatformName, "*"), platformData.appResourcesDestinationDirectoryPath); this.$fs.deleteDirectory(appResourcesDirectoryPath).wait(); } diff --git a/test/npm-support.ts b/test/npm-support.ts index 2a2e66686a..ff5d00cda6 100644 --- a/test/npm-support.ts +++ b/test/npm-support.ts @@ -123,7 +123,8 @@ describe("Npm support tests", () => { frameworkPackageName: "tns-android", normalizedPlatformName: "Android", platformProjectService: { - prepareProject: () => Future.fromResult() + prepareProject: () => Future.fromResult(), + prepareAppResources: () => Future.fromResult() } } }; diff --git a/test/stubs.ts b/test/stubs.ts index 7cb8a456e0..79b60c2a90 100644 --- a/test/stubs.ts +++ b/test/stubs.ts @@ -297,6 +297,9 @@ export class PlatformProjectServiceStub implements IPlatformProjectService { updatePlatform(currentVersion: string, newVersion: string): IFuture { return Future.fromResult(); } + prepareAppResources(appResourcesDirectoryPath: string): IFuture { + return Future.fromResult(); + } } export class ProjectDataService implements IProjectDataService {