Skip to content

Commit d11d208

Browse files
author
Tsvetan Raikov
committed
Fixed: prepare is called twice when livesyncing
1 parent b470af0 commit d11d208

File tree

6 files changed

+19
-15
lines changed

6 files changed

+19
-15
lines changed

lib/commands/appstore-upload.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class PublishIOS implements ICommand {
6363
};
6464
this.$logger.info("Building .ipa with the selected mobile provision and/or certificate.");
6565
// This is not very correct as if we build multiple targets we will try to sign all of them using the signing identity here.
66-
this.$platformService.buildPlatform(platform, iOSBuildConfig).wait();
66+
this.$platformService.prepareAndExecute(platform, () => this.$platformService.buildPlatform(platform, iOSBuildConfig)).wait();
6767
ipaFilePath = this.$platformService.lastOutputPath(platform, { isForDevice: iOSBuildConfig.buildForDevice });
6868
} else {
6969
this.$logger.info("No .ipa, mobile provision or certificate set. Perfect! Now we'll build .xcarchive and let Xcode pick the distribution certificate and provisioning profile for you when exporting .ipa for AppStore submission.");

lib/commands/build.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class BuildCommandBase {
55
executeCore(args: string[], buildConfig?: IBuildConfig): IFuture<void> {
66
return (() => {
77
let platform = args[0].toLowerCase();
8-
this.$platformService.buildPlatform(platform, buildConfig).wait();
8+
this.$platformService.prepareAndExecute(platform, () => this.$platformService.buildPlatform(platform, buildConfig)).wait();
99
if(this.$options.copyTo) {
1010
this.$platformService.copyLastOutput(platform, this.$options.copyTo, {isForDevice: this.$options.forDevice}).wait();
1111
}

lib/definitions/platform.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ interface IPlatformService {
2121
copyLastOutput(platform: string, targetPath: string, settings: {isForDevice: boolean}): IFuture<void>;
2222
lastOutputPath(platform: string, settings: { isForDevice: boolean }): string;
2323
ensurePlatformInstalled(platform: string): IFuture<void>;
24+
25+
prepareAndExecute(platform: string, executeAction: () => IFuture<void>): IFuture<void>;
2426
}
2527

2628
interface IPlatformData {

lib/services/android-debug-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class AndroidDebugService implements IDebugService {
108108
let cachedDeviceOption = this.$options.forDevice;
109109
this.$options.forDevice = true;
110110
if (this.$options.rebuild) {
111-
this.$platformService.buildPlatform(this.platform).wait();
111+
this.$platformService.prepareAndExecute(this.platform, () => this.$platformService.buildPlatform(this.platform)).wait();
112112
}
113113
this.$options.forDevice = !!cachedDeviceOption;
114114

lib/services/ios-debug-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class IOSDebugService implements IDebugService {
8888
return (() => {
8989
let platformData = this.$platformsData.getPlatformData(this.platform);
9090
if (this.$options.rebuild) {
91-
this.$platformService.buildPlatform(this.platform).wait();
91+
this.$platformService.prepareAndExecute(this.platform, () => this.$platformService.buildPlatform(this.platform)).wait();
9292
}
9393
let emulatorPackage = this.$platformService.getLatestApplicationPackageForEmulator(platformData).wait();
9494

lib/services/platform-service.ts

+13-11
Original file line numberDiff line numberDiff line change
@@ -330,23 +330,25 @@ export class PlatformService implements IPlatformService {
330330
public buildPlatform(platform: string, buildConfig?: IBuildConfig): IFuture<void> {
331331
return (() => {
332332
platform = platform.toLowerCase();
333-
if (!this.preparePlatform(platform).wait()) {
334-
this.$errors.failWithoutHelp("Verify that listed files are well-formed and try again the operation.");
335-
}
336-
337333
let platformData = this.$platformsData.getPlatformData(platform);
338334
platformData.platformProjectService.buildProject(platformData.projectRoot, buildConfig).wait();
339335
this.$logger.out("Project successfully built.");
340336
}).future<void>()();
341337
}
342338

339+
public prepareAndExecute(platform: string, executeAction: () => IFuture<void>): IFuture<void> {
340+
return (() => {
341+
platform = platform.toLowerCase();
342+
if (!this.preparePlatform(platform).wait()) {
343+
this.$errors.failWithoutHelp("Verify that listed files are well-formed and try again the operation.");
344+
}
345+
executeAction().wait();
346+
}).future<void>()();
347+
}
348+
343349
public buildForDeploy(platform: string, buildConfig?: IBuildConfig): IFuture<void> {
344350
return (() => {
345351
platform = platform.toLowerCase();
346-
if (!this.preparePlatform(platform).wait()) {
347-
this.$errors.failWithoutHelp("Verify that listed files are well-formed and try again the operation.");
348-
}
349-
350352
let platformData = this.$platformsData.getPlatformData(platform);
351353
platformData.platformProjectService.buildForDeploy(platformData.projectRoot, buildConfig).wait();
352354
this.$logger.out("Project successfully built");
@@ -440,12 +442,12 @@ export class PlatformService implements IPlatformService {
440442
return (() => {
441443
if (!packageFile) {
442444
if (this.$devicesService.isiOSSimulator(device)) {
443-
this.buildForDeploy(platform, buildConfig).wait();
445+
this.prepareAndExecute(platform, () => this.buildForDeploy(platform, buildConfig)).wait();
444446
packageFile = this.getLatestApplicationPackageForEmulator(platformData).wait().packageName;
445447
} else {
446448
buildConfig = buildConfig || {};
447449
buildConfig.buildForDevice = true;
448-
this.buildForDeploy(platform, buildConfig).wait();
450+
this.prepareAndExecute(platform, () => this.buildForDeploy(platform, buildConfig)).wait();
449451
packageFile = this.getLatestApplicationPackageForDevice(platformData).wait().packageName;
450452
}
451453
}
@@ -533,7 +535,7 @@ export class PlatformService implements IPlatformService {
533535
emulatorServices.checkAvailability().wait();
534536
emulatorServices.checkDependencies().wait();
535537

536-
this.buildPlatform(platform, buildConfig).wait();
538+
this.prepareAndExecute(platform, () => this.buildPlatform(platform, buildConfig)).wait();
537539

538540
packageFile = this.getLatestApplicationPackageForEmulator(platformData).wait().packageName;
539541
this.$logger.out("Using ", packageFile);

0 commit comments

Comments
 (0)