Skip to content

Commit 0f36cf2

Browse files
committed
Refactor buildProject
1 parent 6828871 commit 0f36cf2

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

lib/definitions/project.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ interface IPlatformSpecificProjectService {
2626
createProject(projectRoot: string, frameworkDir: string): IFuture<void>;
2727
interpolateData(projectRoot: string): void;
2828
executePlatformSpecificAction(projectRoot: string, frameworkDir: string): void;
29+
buildProject(projectRoot: string): IFuture<void>;
2930
}

lib/services/project-service.ts

+5-24
Original file line numberDiff line numberDiff line change
@@ -236,29 +236,11 @@ class PlatformProjectService implements IPlatformProjectService {
236236

237237
public buildProject(platform: string): IFuture<void> {
238238
return (() => {
239-
this.executePlatformSpecificAction(platform, "buildProject").wait();
240-
}).future<void>()();
241-
}
242-
243-
private executePlatformSpecificAction(platform, functionName: string): IFuture<void> {
244-
return (() => {
245-
var platformProjectService = null;
246-
247-
248-
this.executeFunctionByName(functionName, platformProjectService).wait();
239+
var platformData = this.$platformsData.getPlatformData(platform);
240+
platformData.platformProjectService.buildProject(platformData.projectRoot).wait();
241+
this.$logger.out("Project successfully built");
249242
}).future<void>()();
250243
}
251-
252-
private executeFunctionByName(functionName, context): IFuture<any> {
253-
return (() => {
254-
var namespaces = functionName.split(".");
255-
var func = namespaces.pop();
256-
for (var i = 0; i < namespaces.length; i++) {
257-
context = context[namespaces[i]];
258-
}
259-
return context[func].apply(context).wait();
260-
}).future<any>()();
261-
}
262244
}
263245
$injector.register("platformProjectService", PlatformProjectService);
264246

@@ -323,9 +305,8 @@ class AndroidProjectService implements IPlatformSpecificProjectService {
323305
this.runAndroidUpdate(projectRoot, targetApi).wait();
324306
}
325307

326-
public buildProject(): IFuture<void> {
308+
public buildProject(projectRoot: string): IFuture<void> {
327309
return (() => {
328-
var projectRoot = path.join(this.$projectData.platformsDir, "android");
329310
var buildConfiguration = options.release || "--debug";
330311
var args = this.getAntArgs(buildConfiguration, projectRoot);
331312

@@ -440,7 +421,7 @@ $injector.register("androidProjectService", AndroidProjectService);
440421

441422
class IOSProjectService implements IPlatformSpecificProjectService {
442423
public validate(): void {
443-
424+
444425
}
445426

446427
public checkRequirements(): IFuture<void> {

0 commit comments

Comments
 (0)