@@ -330,23 +330,25 @@ export class PlatformService implements IPlatformService {
330
330
public buildPlatform ( platform : string , buildConfig ?: IBuildConfig ) : IFuture < void > {
331
331
return ( ( ) => {
332
332
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
-
337
333
let platformData = this . $platformsData . getPlatformData ( platform ) ;
338
334
platformData . platformProjectService . buildProject ( platformData . projectRoot , buildConfig ) . wait ( ) ;
339
335
this . $logger . out ( "Project successfully built." ) ;
340
336
} ) . future < void > ( ) ( ) ;
341
337
}
342
338
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
+
343
349
public buildForDeploy ( platform : string , buildConfig ?: IBuildConfig ) : IFuture < void > {
344
350
return ( ( ) => {
345
351
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
-
350
352
let platformData = this . $platformsData . getPlatformData ( platform ) ;
351
353
platformData . platformProjectService . buildForDeploy ( platformData . projectRoot , buildConfig ) . wait ( ) ;
352
354
this . $logger . out ( "Project successfully built" ) ;
@@ -440,12 +442,12 @@ export class PlatformService implements IPlatformService {
440
442
return ( ( ) => {
441
443
if ( ! packageFile ) {
442
444
if ( this . $devicesService . isiOSSimulator ( device ) ) {
443
- this . buildForDeploy ( platform , buildConfig ) . wait ( ) ;
445
+ this . prepareAndExecute ( platform , ( ) => this . buildForDeploy ( platform , buildConfig ) ) . wait ( ) ;
444
446
packageFile = this . getLatestApplicationPackageForEmulator ( platformData ) . wait ( ) . packageName ;
445
447
} else {
446
448
buildConfig = buildConfig || { } ;
447
449
buildConfig . buildForDevice = true ;
448
- this . buildForDeploy ( platform , buildConfig ) . wait ( ) ;
450
+ this . prepareAndExecute ( platform , ( ) => this . buildForDeploy ( platform , buildConfig ) ) . wait ( ) ;
449
451
packageFile = this . getLatestApplicationPackageForDevice ( platformData ) . wait ( ) . packageName ;
450
452
}
451
453
}
@@ -533,7 +535,7 @@ export class PlatformService implements IPlatformService {
533
535
emulatorServices . checkAvailability ( ) . wait ( ) ;
534
536
emulatorServices . checkDependencies ( ) . wait ( ) ;
535
537
536
- this . buildPlatform ( platform , buildConfig ) . wait ( ) ;
538
+ this . prepareAndExecute ( platform , ( ) => this . buildPlatform ( platform , buildConfig ) ) . wait ( ) ;
537
539
538
540
packageFile = this . getLatestApplicationPackageForEmulator ( platformData ) . wait ( ) . packageName ;
539
541
this . $logger . out ( "Using " , packageFile ) ;
0 commit comments