-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathadd-platform.ts
43 lines (34 loc) · 1.4 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
41
42
43
import { ValidatePlatformCommandBase } from "./command-base";
export class AddPlatformCommand extends ValidatePlatformCommandBase implements ICommand {
public allowedParameters: ICommandParameter[] = [];
constructor($options: IOptions,
$platformService: IPlatformService,
$projectData: IProjectData,
$platformsData: IPlatformsData,
private $errors: IErrors) {
super($options, $platformsData, $platformService, $projectData);
this.$projectData.initializeProjectData();
}
public async execute(args: string[]): Promise<void> {
await this.$platformService.addPlatforms(args, this.$options.platformTemplate, this.$projectData, this.$options, this.$options.frameworkPath);
}
public async canExecute(args: string[]): Promise<ICanExecuteCommandOutput> {
if (!args || args.length === 0) {
this.$errors.fail("No platform specified. Please specify a platform to add");
}
let canExecute = true;
for (const arg of args) {
this.$platformService.validatePlatform(arg, this.$projectData);
if (!this.$platformService.isPlatformSupportedForOS(arg, this.$projectData)) {
this.$errors.fail(`Applications for platform ${arg} can not be built on this OS`);
}
const output = await super.canExecuteCommandBase(arg);
canExecute = canExecute && output.canExecute;
}
return {
canExecute,
suppressCommandHelp: !canExecute
};
}
}
$injector.registerCommand("platform|add", AddPlatformCommand);