Skip to content

Commit a947306

Browse files
Fatme HavaluovaFatme Havaluova
Fatme Havaluova
authored and
Fatme Havaluova
committed
Implement build command as hierarchical
1 parent 7ca1ca2 commit a947306

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed

lib/bootstrap.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ $injector.requireCommand("platform|update", "./commands/update-platform");
2929
$injector.requireCommand("run", "./commands/run");
3030
$injector.requireCommand("debug", "./commands/debug");
3131
$injector.requireCommand("prepare", "./commands/prepare");
32-
$injector.requireCommand("build", "./commands/build");
32+
$injector.requireCommand("build|ios", "./commands/build");
33+
$injector.requireCommand("build|android", "./commands/build");
3334
$injector.requireCommand("deploy", "./commands/deploy");
3435
$injector.requireCommand("emulate|android", "./commands/emulate");
3536
$injector.requireCommand("emulate|ios", "./commands/emulate");

lib/commands/build.ts

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,39 @@
11
///<reference path="../.d.ts"/>
22
"use strict";
33

4-
export class BuildCommand implements ICommand {
5-
constructor(private $platformService: IPlatformService,
6-
private $platformCommandParameter: ICommandParameter) { }
4+
export class BuildCommandBase {
5+
constructor(private $platformService: IPlatformService) { }
76

8-
execute(args: string[]): IFuture<void> {
9-
return this.$platformService.buildPlatform(args[0]);
7+
executeCore(args: string[]): IFuture<void> {
8+
return this.$platformService.buildPlatform(args[0]);
109
}
10+
}
11+
12+
export class BuildIosCommand extends BuildCommandBase implements ICommand {
13+
constructor($platformService: IPlatformService,
14+
private $platformsData: IPlatformsData) {
15+
super($platformService);
16+
}
17+
18+
public allowedParameters: ICommandParameter[] = [];
19+
20+
public execute(args: string[]): IFuture<void> {
21+
return this.executeCore([this.$platformsData.availablePlatforms.iOS]);
22+
}
23+
}
24+
$injector.registerCommand("build|ios", BuildIosCommand);
25+
26+
27+
export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
28+
constructor($platformService: IPlatformService,
29+
private $platformsData: IPlatformsData) {
30+
super($platformService);
31+
}
32+
33+
public allowedParameters: ICommandParameter[] = [];
1134

12-
allowedParameters = [this.$platformCommandParameter];
35+
public execute(args: string[]): IFuture<void> {
36+
return this.executeCore([this.$platformsData.availablePlatforms.Android]);
37+
}
1338
}
14-
$injector.registerCommand("build", BuildCommand);
39+
$injector.registerCommand("build|android", BuildAndroidCommand);

lib/services/platform-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export class PlatformService implements IPlatformService {
165165
public buildPlatform(platform: string): IFuture<void> {
166166
return (() => {
167167
platform = platform.toLowerCase();
168-
this.preparePlatform(platform);
168+
this.preparePlatform(platform).wait();
169169

170170
var platformData = this.$platformsData.getPlatformData(platform);
171171
platformData.platformProjectService.buildProject(platformData.projectRoot).wait();

0 commit comments

Comments
 (0)