Skip to content

Fix broken android prepare #597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/definitions/project.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface IPlatformProjectService {
afterCreateProject(projectRoot: string): IFuture<void>;
buildProject(projectRoot: string): IFuture<void>;
prepareProject(): IFuture<void>;
prepareAppResources(appResourcesDirectoryPath: string): IFuture<void>;
isPlatformPrepared(projectRoot: string): IFuture<boolean>;
addLibrary(platformData: IPlatformData, libraryPath: string): IFuture<void>;
canUpdatePlatform(currentVersion: string, newVersion: string): IFuture<boolean>;
Expand Down
10 changes: 10 additions & 0 deletions lib/services/android-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ class AndroidProjectService implements IPlatformProjectService {
public isPlatformPrepared(projectRoot: string): IFuture<boolean> {
return this.$fs.exists(path.join(projectRoot, "assets", constants.APP_FOLDER_NAME));
}

public prepareAppResources(appResourcesDirectoryPath: string): IFuture<void> {
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<void>()();
}

private parseProjectProperties(projDir: string, destDir: string): void {
let projProp = path.join(projDir, "project.properties");
Expand Down
4 changes: 4 additions & 0 deletions lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ class IOSProjectService implements IPlatformProjectService {
}).future<void>()();
}

public prepareAppResources(appResourcesDirectoryPath: string): IFuture<void> {
return this.$fs.deleteDirectory(this.platformData.appResourcesDestinationDirectoryPath);
}

private replace(name: string): string {
if(_.startsWith(name, '"')) {
name = name.substr(1, name.length-2);
Expand Down
4 changes: 2 additions & 2 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
3 changes: 2 additions & 1 deletion test/npm-support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ describe("Npm support tests", () => {
frameworkPackageName: "tns-android",
normalizedPlatformName: "Android",
platformProjectService: {
prepareProject: () => Future.fromResult()
prepareProject: () => Future.fromResult(),
prepareAppResources: () => Future.fromResult()
}
}
};
Expand Down
3 changes: 3 additions & 0 deletions test/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ export class PlatformProjectServiceStub implements IPlatformProjectService {
updatePlatform(currentVersion: string, newVersion: string): IFuture<void> {
return Future.fromResult();
}
prepareAppResources(appResourcesDirectoryPath: string): IFuture<void> {
return Future.fromResult();
}
}

export class ProjectDataService implements IProjectDataService {
Expand Down