Skip to content

Commit b29fa09

Browse files
committed
Merge pull request #1815 from NativeScript/availableDevices
emulate --availableDevices fixed
2 parents 0fede93 + bf64ddf commit b29fa09

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

lib/services/platform-service.ts

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
///<reference path="../.d.ts"/>
22
"use strict";
33

4+
import * as child_process from "child_process";
45
import * as path from "path";
56
import * as shell from "shelljs";
67
import * as constants from "../constants";
@@ -482,8 +483,28 @@ export class PlatformService implements IPlatformService {
482483
}
483484

484485
public deployOnEmulator(platform: string, buildConfig?: IBuildConfig): IFuture<void> {
485-
this.$options.emulator = true;
486-
return this.deployOnDevice(platform, buildConfig);
486+
platform = platform.toLowerCase();
487+
488+
if (this.$options.availableDevices) {
489+
return (() => {
490+
let callback = (error: Error, stdout: Buffer, stderr: Buffer) => {
491+
if (error !== null) {
492+
this.$errors.fail(error);
493+
} else {
494+
this.$logger.info(stdout);
495+
}
496+
};
497+
498+
if (this.$mobileHelper.isiOSPlatform(platform)) {
499+
child_process.exec("instruments -s devices", callback);
500+
} else if (this.$mobileHelper.isAndroidPlatform(platform)) {
501+
child_process.exec("android list avd", callback);
502+
}
503+
}).future<void>()();
504+
} else {
505+
this.$options.emulator = true;
506+
return this.deployOnDevice(platform, buildConfig);
507+
}
487508
}
488509

489510
public validatePlatform(platform: string): void {

0 commit comments

Comments
 (0)