Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 108bc3d

Browse files
Fatme HavaluovaFatme Havaluova
Fatme Havaluova
authored and
Fatme Havaluova
committed
Fix emulate-livesync-emulate
Fixes NativeScript/nativescript-cli#1031
1 parent 95ae6b3 commit 108bc3d

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

definitions/mobile.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ declare module Mobile {
283283
checkDependencies(): IFuture<void>;
284284
checkAvailability(dependsOnProject?: boolean): IFuture<void>;
285285
startEmulator(app: string, emulatorOptions?: IEmulatorOptions): IFuture<void>;
286+
getEmulatorId?(): IFuture<string>;
286287
}
287288

288289
interface IiOSSimulatorService extends IEmulatorPlatformServices {

mobile/android/android-emulator-services.ts

+20-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ class AndroidEmulatorServices implements Mobile.IEmulatorPlatformServices {
4545
this.adbFilePath = this.$staticConfig.getAdbFilePath().wait();
4646
}
4747

48+
public getEmulatorId(): IFuture<string> {
49+
return (() => {
50+
let image = this.getEmulatorImage().wait();
51+
if(!image) {
52+
this.$errors.fail("Could not find an emulator image to run your project.");
53+
}
54+
55+
let emulatorId = this.startEmulatorInstance(image).wait();
56+
return emulatorId;
57+
}).future<string>()();
58+
}
59+
4860
public checkDependencies(): IFuture<void> {
4961
return (() => {
5062
this.checkAndroidSDKConfiguration().wait();
@@ -77,6 +89,13 @@ class AndroidEmulatorServices implements Mobile.IEmulatorPlatformServices {
7789
}).future<void>()();
7890
}
7991

92+
private getEmulatorImage(): IFuture<string> {
93+
return (() => {
94+
let image = this.$options.avd || this.$options.geny || this.getBestFit().wait();
95+
return image;
96+
}).future<string>()();
97+
}
98+
8099
public checkAvailability(): IFuture<void> {
81100
return (() => {
82101
let platform = this.$devicePlatformsConstants.Android;
@@ -92,7 +111,7 @@ class AndroidEmulatorServices implements Mobile.IEmulatorPlatformServices {
92111
this.$errors.fail("You cannot specify both --avd and --geny options. Please use only one of them.");
93112
}
94113

95-
let image = this.$options.avd || this.$options.geny || this.getBestFit().wait();
114+
let image = this.getEmulatorImage().wait();
96115
if(image) {
97116
this.startEmulatorCore(app, emulatorOptions.appId, image).wait();
98117
} else {

0 commit comments

Comments
 (0)