@@ -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