Skip to content

Commit 941400e

Browse files
authored
Fixed: Show error message when --device <device id> is invalid (#2412)
1 parent 19b5654 commit 941400e

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
@@ -458,16 +458,25 @@ export class PlatformService implements IPlatformService {
458458
if (this.$options.availableDevices) {
459459
return this.$emulatorPlatformService.listAvailableEmulators(platform);
460460
}
461+
this.$options.emulator = true;
461462
if (this.$options.device) {
462463
let info = this.$emulatorPlatformService.getEmulatorInfo(platform, this.$options.device).wait();
463464
if (info) {
464465
if (!info.isRunning) {
465466
this.$emulatorPlatformService.startEmulator(info).wait();
466467
}
467468
this.$options.device = null;
469+
} else {
470+
this.$devicesService.initialize({ platform: platform, deviceId: this.$options.device }).wait();
471+
let found: Mobile.IDeviceInfo[] = [];
472+
if (this.$devicesService.hasDevices) {
473+
found = this.$devicesService.getDevices().filter((device:Mobile.IDeviceInfo) => device.identifier === this.$options.device);
474+
}
475+
if (found.length === 0) {
476+
this.$errors.fail("Cannot find device with name: %s", this.$options.device);
477+
}
468478
}
469479
}
470-
this.$options.emulator = true;
471480
this.deployPlatform(platform).wait();
472481
return this.runPlatform(platform);
473482
}

0 commit comments

Comments
 (0)