Skip to content

Commit 855b6e1

Browse files
committed
fix(platform-add): respect nativePlatformStatus property from .nsprepare file when adding the platform
As the preview command add only the .js part of the platform, we need to check nativePlatformStatus in order to decide correctly if platform add is necessary
1 parent a359559 commit 855b6e1

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/services/platform-service.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,28 @@ export class PlatformService extends EventEmitter implements IPlatformService {
6969
this.validatePlatform(platform, projectData);
7070
const platformPath = path.join(projectData.platformsDir, platform);
7171

72-
if (this.$fs.exists(platformPath)) {
72+
const isPlatformAdded = this.isPlatformAdded(platform, platformPath, projectData);
73+
if (isPlatformAdded) {
7374
this.$errors.failWithoutHelp(`Platform ${platform} already added`);
7475
}
7576

7677
await this.addPlatform(platform.toLowerCase(), platformTemplate, projectData, config, frameworkPath);
7778
}
7879
}
7980

81+
private isPlatformAdded(platform: string, platformPath: string, projectData: IProjectData): boolean {
82+
if (!this.$fs.exists(platformPath)) {
83+
return false;
84+
}
85+
86+
const prepareInfo = this.$projectChangesService.getPrepareInfo(platform, projectData);
87+
if (!prepareInfo) {
88+
return true;
89+
}
90+
91+
return prepareInfo.nativePlatformStatus !== constants.NativePlatformStatus.requiresPlatformAdd;
92+
}
93+
8094
public getCurrentPlatformVersion(platform: string, projectData: IProjectData): string {
8195
const platformData = this.$platformsData.getPlatformData(platform, projectData);
8296
const currentPlatformData: any = this.$projectDataService.getNSValue(projectData.projectDir, platformData.frameworkPackageName);

0 commit comments

Comments
 (0)