From bf64ddfa4de378bfe7cba047b7e891613e6765c9 Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Wed, 8 Jun 2016 09:40:02 +0300 Subject: [PATCH] emulate --availableDevices fixed --- lib/services/platform-service.ts | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/services/platform-service.ts b/lib/services/platform-service.ts index 4ad2c39a72..5b61922ebe 100644 --- a/lib/services/platform-service.ts +++ b/lib/services/platform-service.ts @@ -1,6 +1,7 @@ /// "use strict"; +import * as child_process from "child_process"; import * as path from "path"; import * as shell from "shelljs"; import * as constants from "../constants"; @@ -482,8 +483,28 @@ export class PlatformService implements IPlatformService { } public deployOnEmulator(platform: string, buildConfig?: IBuildConfig): IFuture { - this.$options.emulator = true; - return this.deployOnDevice(platform, buildConfig); + platform = platform.toLowerCase(); + + if (this.$options.availableDevices) { + return (() => { + let callback = (error: Error, stdout: Buffer, stderr: Buffer) => { + if (error !== null) { + this.$errors.fail(error); + } else { + this.$logger.info(stdout); + } + }; + + if (this.$mobileHelper.isiOSPlatform(platform)) { + child_process.exec("instruments -s devices", callback); + } else if (this.$mobileHelper.isAndroidPlatform(platform)) { + child_process.exec("android list avd", callback); + } + }).future()(); + } else { + this.$options.emulator = true; + return this.deployOnDevice(platform, buildConfig); + } } public validatePlatform(platform: string): void {