-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathplatform-clean.ts
44 lines (36 loc) · 1.45 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
42
43
44
export class CleanCommand implements ICommand {
public allowedParameters: ICommandParameter[] = [];
constructor(
private $errors: IErrors,
private $options: IOptions,
private $platformCommandHelper: IPlatformCommandHelper,
private $platformValidationService: IPlatformValidationService,
private $platformEnvironmentRequirements: IPlatformEnvironmentRequirements,
private $projectData: IProjectData
) {
this.$projectData.initializeProjectData();
}
public async execute(args: string[]): Promise<void> {
await this.$platformCommandHelper.cleanPlatforms(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 clean.");
}
_.each(args, platform => {
this.$platformValidationService.validatePlatform(platform, this.$projectData);
});
for (const platform of args) {
this.$platformValidationService.validatePlatformInstalled(platform, this.$projectData);
const currentRuntimeVersion = this.$platformCommandHelper.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);