Skip to content

Throw error if commands are executed without platform #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 14, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,8 @@ export class PlatformService implements IPlatformService {

public preparePlatform(platform: string): IFuture<void> {
return (() => {
platform = platform.toLowerCase();

this.validatePlatformInstalled(platform);
platform = platform.toLowerCase();

var platformData = this.$platformsData.getPlatformData(platform);
var platformProjectService = platformData.platformProjectService;
Expand All @@ -156,8 +155,8 @@ export class PlatformService implements IPlatformService {

public buildPlatform(platform: string): IFuture<void> {
return (() => {
platform = platform.toLowerCase();
this.validatePlatformInstalled(platform);
platform = platform.toLowerCase();

var platformData = this.$platformsData.getPlatformData(platform);
platformData.platformProjectService.buildProject(platformData.projectRoot).wait();
Expand All @@ -167,9 +166,8 @@ export class PlatformService implements IPlatformService {

public runPlatform(platform: string): IFuture<void> {
return (() => {
platform = platform.toLowerCase();

this.validatePlatformInstalled(platform);
platform = platform.toLowerCase();

this.preparePlatform(platform).wait();
this.buildPlatform(platform).wait();
Expand All @@ -193,6 +191,12 @@ export class PlatformService implements IPlatformService {
}

private validatePlatform(platform: string): void {
if(!platform) {
this.$errors.fail("No platform specified.")
}

platform = platform.toLowerCase();

if (!this.isValidPlatform(platform)) {
this.$errors.fail("Invalid platform %s. Valid platforms are %s.", platform, helpers.formatListOfNames(this.$platformsData.platformsNames));
}
Expand Down