-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathadd-platform.ts
32 lines (26 loc) · 1.11 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
export class AddPlatformCommand implements ICommand {
public allowedParameters: ICommandParameter[] = [];
constructor(private $options: IOptions,
private $platformService: IPlatformService,
private $projectData: IProjectData,
private $platformsData: IPlatformsData,
private $errors: IErrors) {
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<boolean> {
if (!args || args.length === 0) {
this.$errors.fail("No platform specified. Please specify a platform to add");
}
for (let arg of args) {
this.$platformService.validatePlatform(arg, this.$projectData);
const platformData = this.$platformsData.getPlatformData(arg, this.$projectData);
const platformProjectService = platformData.platformProjectService;
await platformProjectService.validate(this.$projectData);
}
return true;
}
}
$injector.registerCommand("platform|add", AddPlatformCommand);