-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathadd-platform.ts
40 lines (31 loc) · 1.38 KB
/
add-platform.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
import { ValidatePlatformCommandBase } from "./command-base";
export class AddPlatformCommand extends ValidatePlatformCommandBase implements ICommand {
public allowedParameters: ICommandParameter[] = [];
constructor($options: IOptions,
private $platformCommandHelper: IPlatformCommandHelper,
$platformValidationService: IPlatformValidationService,
$projectData: IProjectData,
$platformsDataService: IPlatformsDataService,
private $errors: IErrors) {
super($options, $platformsDataService, $platformValidationService, $projectData);
this.$projectData.initializeProjectData();
}
public async execute(args: string[]): Promise<void> {
await this.$platformCommandHelper.addPlatforms(args, this.$projectData, this.$options.frameworkPath);
}
public async canExecute(args: string[]): Promise<boolean> {
if (!args || args.length === 0) {
this.$errors.failWithHelp("No platform specified. Please specify a platform to add.");
}
let canExecute = true;
for (const arg of args) {
this.$platformValidationService.validatePlatform(arg, this.$projectData);
if (!this.$platformValidationService.isPlatformSupportedForOS(arg, this.$projectData)) {
this.$errors.fail(`Applications for platform ${arg} cannot be built on this OS`);
}
canExecute = await super.canExecuteCommandBase(arg);
}
return canExecute;
}
}
$injector.registerCommand("platform|add", AddPlatformCommand);