Skip to content

Commit 368f905

Browse files
committed
Validate platform in canExecute function
1 parent f95a53a commit 368f905

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

lib/commands/debug.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,30 @@
22
"use strict";
33

44
export class DebugPlatformCommand implements ICommand {
5-
constructor(private debugService: IDebugService) { }
5+
constructor(private debugService: IDebugService,
6+
private $platformService: IPlatformService) { }
67

78
execute(args: string[]): IFuture<void> {
89
return this.debugService.debug();
910
}
10-
11+
1112
allowedParameters: ICommandParameter[] = [];
1213
}
1314

1415
export class DebugIOSCommand extends DebugPlatformCommand {
15-
constructor(private $iOSDebugService: IDebugService) {
16-
super($iOSDebugService);
17-
}
16+
constructor(private $iOSDebugService: IDebugService,
17+
$platformService: IPlatformService,
18+
private $platformsData: IPlatformsData) {
19+
super($iOSDebugService, $platformService);
20+
}
1821
}
1922
$injector.registerCommand("debug|ios", DebugIOSCommand);
2023

2124
export class DebugAndroidCommand extends DebugPlatformCommand {
22-
constructor(private $androidDebugService: IDebugService) {
23-
super($androidDebugService);
25+
constructor(private $androidDebugService: IDebugService,
26+
$platformService: IPlatformService,
27+
private $platformsData: IPlatformsData) {
28+
super($androidDebugService, $platformService);
2429
}
2530
}
2631
$injector.registerCommand("debug|android", DebugAndroidCommand);

lib/commands/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class DeployOnDeviceCommand implements ICommand {
88
execute(args: string[]): IFuture<void> {
99
return this.$platformService.deployOnDevice(args[0]);
1010
}
11-
11+
1212
allowedParameters = [this.$platformCommandParameter];
1313
}
1414
$injector.registerCommand("deploy", DeployOnDeviceCommand);

lib/commands/prepare.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ export class PrepareCommand implements ICommand {
66
private $platformCommandParameter: ICommandParameter) { }
77

88
execute(args: string[]): IFuture<void> {
9-
return (() => {
10-
this.$platformService.preparePlatform(args[0]).wait();
11-
}).future<void>()();
9+
return this.$platformService.preparePlatform(args[0]);
1210
}
13-
11+
1412
allowedParameters = [this.$platformCommandParameter];
1513
}
1614
$injector.registerCommand("prepare", PrepareCommand);

lib/commands/run.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export class RunCommandBase {
66

77
public executeCore(args: string[]): IFuture<void> {
88
return this.$platformService.runPlatform(args[0]);
9-
}
9+
}
1010
}
1111

1212
export class RunIosCommand extends RunCommandBase implements ICommand {

lib/services/platform-service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ export class PlatformService implements IPlatformService {
146146

147147
public preparePlatform(platform: string): IFuture<void> {
148148
return (() => {
149+
this.validatePlatform(platform);
150+
149151
platform = platform.toLowerCase();
150152

151153
var platformData = this.$platformsData.getPlatformData(platform);

0 commit comments

Comments
 (0)