Skip to content

Commit 5cbfd83

Browse files
tzraikovTsvetan Raikov
authored and
Tsvetan Raikov
committed
Fixed: Show error message when --device <device id> is invalid (#2412)
1 parent 52f2803 commit 5cbfd83

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/services/platform-service.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -439,16 +439,25 @@ export class PlatformService implements IPlatformService {
439439
if (this.$options.availableDevices) {
440440
return this.$emulatorPlatformService.listAvailableEmulators(platform);
441441
}
442+
this.$options.emulator = true;
442443
if (this.$options.device) {
443444
let info = this.$emulatorPlatformService.getEmulatorInfo(platform, this.$options.device).wait();
444445
if (info) {
445446
if (!info.isRunning) {
446447
this.$emulatorPlatformService.startEmulator(info).wait();
447448
}
448449
this.$options.device = null;
450+
} else {
451+
this.$devicesService.initialize({ platform: platform, deviceId: this.$options.device }).wait();
452+
let found: Mobile.IDeviceInfo[] = [];
453+
if (this.$devicesService.hasDevices) {
454+
found = this.$devicesService.getDevices().filter((device:Mobile.IDeviceInfo) => device.identifier === this.$options.device);
455+
}
456+
if (found.length === 0) {
457+
this.$errors.fail("Cannot find device with name: %s", this.$options.device);
458+
}
449459
}
450460
}
451-
this.$options.emulator = true;
452461
this.deployPlatform(platform).wait();
453462
return this.runPlatform(platform);
454463
}

0 commit comments

Comments
 (0)