-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathcreate-project.ts
33 lines (26 loc) · 1.07 KB
/
create-project.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
import * as constants from "../constants";
export class CreateProjectCommand implements ICommand {
constructor(private $projectService: IProjectService,
private $errors: IErrors,
private $options: IOptions,
private $stringParameterBuilder: IStringParameterBuilder) { }
public enableHooks = false;
execute(args: string[]): IFuture<void> {
return (() => {
if ((this.$options.tsc || this.$options.ng) && this.$options.template) {
this.$errors.fail("You cannot use --ng or --tsc options together with --template.");
}
let selectedTemplate: string;
if (this.$options.tsc) {
selectedTemplate = constants.TYPESCRIPT_NAME;
} else if (this.$options.ng) {
selectedTemplate = constants.ANGULAR_NAME;
} else {
selectedTemplate = this.$options.template;
}
this.$projectService.createProject(args[0], selectedTemplate).wait();
}).future<void>()();
}
public allowedParameters: ICommandParameter[] = [this.$stringParameterBuilder.createMandatoryParameter("Project name cannot be empty.")];
}
$injector.registerCommand("create", CreateProjectCommand);