Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions lib/commands/debug.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export class DebugPlatformCommand implements ICommand {
constructor(private debugService: IDebugService,
private $devicesService: Mobile.IDevicesService,
private $errors: IErrors,
private $logger: ILogger,
protected $options: IOptions) { }

execute(args: string[]): IFuture<void> {
Expand All @@ -13,14 +13,16 @@
canExecute(args: string[]): IFuture<boolean> {
return ((): boolean => {
this.$devicesService.initialize({ platform: this.debugService.platform, deviceId: this.$options.device }).wait();
if(this.$options.emulator) {
// Start emulator if --emulator is selected or no devices found.
if(this.$options.emulator || this.$devicesService.deviceCount === 0) {
return true;
}

if(this.$devicesService.deviceCount === 0) {
this.$errors.failWithoutHelp("No devices detected. Connect a device and try again.");
} else if (this.$devicesService.deviceCount > 1) {
this.$errors.fail("Cannot debug on multiple devices. Select device with --device option.");
if (this.$devicesService.deviceCount > 1) {
// Starting debugger on emulator.
this.$options.emulator = true;

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);
}

return true;
Expand All @@ -31,19 +33,19 @@
export class DebugIOSCommand extends DebugPlatformCommand {
constructor($iOSDebugService: IDebugService,
$devicesService: Mobile.IDevicesService,
$errors: IErrors,
$logger: ILogger,
$options: IOptions) {
super($iOSDebugService, $devicesService, $errors, $options);
super($iOSDebugService, $devicesService, $logger, $options);
}
}
$injector.registerCommand("debug|ios", DebugIOSCommand);

export class DebugAndroidCommand extends DebugPlatformCommand {
constructor($androidDebugService: IDebugService,
$devicesService: Mobile.IDevicesService,
$errors: IErrors,
$logger: ILogger,
$options: IOptions) {
super($androidDebugService, $devicesService, $errors, $options);
super($androidDebugService, $devicesService, $logger, $options);
}
}
$injector.registerCommand("debug|android", DebugAndroidCommand);
4 changes: 4 additions & 0 deletions lib/services/ios-debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class IOSDebugService implements IDebugService {
this.$errors.failWithoutHelp("Expected exactly one of the --debug-brk or --start options.");
}

if (this.$devicesService.isOnlyiOSSimultorRunning() || this.$devicesService.deviceCount === 0) {
this.$options.emulator = true;
}

if (this.$options.emulator) {
if (this.$options.debugBrk) {
return this.emulatorDebugBrk(true);
Expand Down