|
1 | 1 | export class DebugPlatformCommand implements ICommand { |
2 | 2 | constructor(private debugService: IDebugService, |
3 | 3 | private $devicesService: Mobile.IDevicesService, |
4 | | - private $errors: IErrors, |
| 4 | + private $logger: ILogger, |
5 | 5 | protected $options: IOptions) { } |
6 | 6 |
|
7 | 7 | execute(args: string[]): IFuture<void> { |
|
13 | 13 | canExecute(args: string[]): IFuture<boolean> { |
14 | 14 | return ((): boolean => { |
15 | 15 | this.$devicesService.initialize({ platform: this.debugService.platform, deviceId: this.$options.device }).wait(); |
16 | | - if(this.$options.emulator) { |
| 16 | + // Start emulator if --emulator is selected or no devices found. |
| 17 | + if(this.$options.emulator || this.$devicesService.deviceCount === 0) { |
17 | 18 | return true; |
18 | 19 | } |
19 | 20 |
|
20 | | - if(this.$devicesService.deviceCount === 0) { |
21 | | - this.$errors.failWithoutHelp("No devices detected. Connect a device and try again."); |
22 | | - } else if (this.$devicesService.deviceCount > 1) { |
23 | | - this.$errors.fail("Cannot debug on multiple devices. Select device with --device option."); |
| 21 | + if (this.$devicesService.deviceCount > 1) { |
| 22 | + // Starting debugger on emulator. |
| 23 | + this.$options.emulator = true; |
| 24 | + |
| 25 | + this.$logger.warn("Multiple devices found! Starting debugger on emulator. If you want to debug on specific device please select device with --device option.".yellow.bold); |
24 | 26 | } |
25 | 27 |
|
26 | 28 | return true; |
|
31 | 33 | export class DebugIOSCommand extends DebugPlatformCommand { |
32 | 34 | constructor($iOSDebugService: IDebugService, |
33 | 35 | $devicesService: Mobile.IDevicesService, |
34 | | - $errors: IErrors, |
| 36 | + $logger: ILogger, |
35 | 37 | $options: IOptions) { |
36 | | - super($iOSDebugService, $devicesService, $errors, $options); |
| 38 | + super($iOSDebugService, $devicesService, $logger, $options); |
37 | 39 | } |
38 | 40 | } |
39 | 41 | $injector.registerCommand("debug|ios", DebugIOSCommand); |
40 | 42 |
|
41 | 43 | export class DebugAndroidCommand extends DebugPlatformCommand { |
42 | 44 | constructor($androidDebugService: IDebugService, |
43 | 45 | $devicesService: Mobile.IDevicesService, |
44 | | - $errors: IErrors, |
| 46 | + $logger: ILogger, |
45 | 47 | $options: IOptions) { |
46 | | - super($androidDebugService, $devicesService, $errors, $options); |
| 48 | + super($androidDebugService, $devicesService, $logger, $options); |
47 | 49 | } |
48 | 50 | } |
49 | 51 | $injector.registerCommand("debug|android", DebugAndroidCommand); |
0 commit comments