-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathplatform-clean.ts
41 lines (33 loc) · 1.32 KB
/
platform-clean.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
export class CleanCommand implements ICommand {
public allowedParameters: ICommandParameter[] = [];
constructor(private $options: IOptions,
private $projectData: IProjectData,
private $platformService: IPlatformService,
private $errors: IErrors,
private $platformEnvironmentRequirements: IPlatformEnvironmentRequirements) {
this.$projectData.initializeProjectData();
}
public async execute(args: string[]): Promise<void> {
await this.$platformService.cleanPlatforms(args, this.$projectData, this.$options);
}
public async canExecute(args: string[]): Promise<boolean> {
if (!args || args.length === 0) {
this.$errors.fail("No platform specified. Please specify a platform to clean");
}
_.each(args, platform => {
this.$platformService.validatePlatform(platform, this.$projectData);
});
for (const platform of args) {
this.$platformService.validatePlatformInstalled(platform, this.$projectData);
const currentRuntimeVersion = this.$platformService.getCurrentPlatformVersion(platform, this.$projectData);
await this.$platformEnvironmentRequirements.checkEnvironmentRequirements({
platform,
projectDir: this.$projectData.projectDir,
runtimeVersion: currentRuntimeVersion,
options: this.$options
});
}
return true;
}
}
$injector.registerCommand("platform|clean", CleanCommand);