-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathdebug.ts
52 lines (44 loc) · 1.61 KB
/
debug.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
///<reference path="../.d.ts"/>
"use strict";
export class DebugPlatformCommand implements ICommand {
constructor(private debugService: IDebugService,
private $devicesService: Mobile.IDevicesService,
private $errors: IErrors,
protected $options: IOptions) { }
execute(args: string[]): IFuture<void> {
return this.debugService.debug();
}
allowedParameters: ICommandParameter[] = [];
canExecute(args: string[]): IFuture<boolean> {
return ((): boolean => {
this.$devicesService.initialize({ platform: this.debugService.platform, deviceId: this.$options.device }).wait();
if(this.$options.emulator) {
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.");
}
return true;
}).future<boolean>()();
}
}
export class DebugIOSCommand extends DebugPlatformCommand {
constructor($iOSDebugService: IDebugService,
$devicesService: Mobile.IDevicesService,
$errors: IErrors,
$options: IOptions) {
super($iOSDebugService, $devicesService, $errors, $options);
}
}
$injector.registerCommand("debug|ios", DebugIOSCommand);
export class DebugAndroidCommand extends DebugPlatformCommand {
constructor($androidDebugService: IDebugService,
$devicesService: Mobile.IDevicesService,
$errors: IErrors,
$options: IOptions) {
super($androidDebugService, $devicesService, $errors, $options);
}
}
$injector.registerCommand("debug|android", DebugAndroidCommand);