@@ -482,8 +482,34 @@ export class PlatformService implements IPlatformService {
482
482
}
483
483
484
484
public deployOnEmulator ( platform : string , buildConfig ?: IBuildConfig ) : IFuture < void > {
485
- this . $options . emulator = true ;
486
- return this . deployOnDevice ( platform , buildConfig ) ;
485
+ platform = platform . toLowerCase ( ) ;
486
+
487
+ if ( this . $options . availableDevices ) {
488
+ return ( ( ) => {
489
+ let exec = require ( "child_process" ) . exec ;
490
+
491
+ if ( this . $mobileHelper . isiOSPlatform ( platform ) ) {
492
+ exec ( "instruments -s devices" , ( error : Error , stdout : string , stderr : string ) => {
493
+ if ( error !== null ) {
494
+ this . $errors . fail ( error ) ;
495
+ } else {
496
+ this . $logger . info ( stdout ) ;
497
+ }
498
+ } ) ;
499
+ } else if ( this . $mobileHelper . isAndroidPlatform ( platform ) ) {
500
+ exec ( "android list avd" , ( error : Error , stdout : string , stderr : string ) => {
501
+ if ( error !== null ) {
502
+ this . $errors . fail ( error ) ;
503
+ } else {
504
+ this . $logger . info ( stdout ) ;
505
+ }
506
+ } ) ;
507
+ }
508
+ } ) . future < void > ( ) ( ) ;
509
+ } else {
510
+ this . $options . emulator = true ;
511
+ return this . deployOnDevice ( platform , buildConfig ) ;
512
+ }
487
513
}
488
514
489
515
public validatePlatform ( platform : string ) : void {
@@ -691,4 +717,4 @@ export class PlatformService implements IPlatformService {
691
717
} ) . future < void > ( ) ( ) ;
692
718
}
693
719
}
694
- $injector . register ( "platformService" , PlatformService ) ;
720
+ $injector . register ( "platformService" , PlatformService ) ;
0 commit comments