Skip to content

Commit 9b7d243

Browse files
author
Vladimir Enchev
committed
emulate --availableDevices fixed
1 parent 0fede93 commit 9b7d243

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

lib/services/platform-service.ts

+28-2
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,34 @@ export class PlatformService implements IPlatformService {
482482
}
483483

484484
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+
}
487513
}
488514

489515
public validatePlatform(platform: string): void {

0 commit comments

Comments
 (0)