Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Fix appid inconsistent - https://github.com/NativeScript/nativescript-cli/issues/413 #308

Merged
merged 1 commit into from
May 4, 2015
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ interface ISpawnFromEventOptions {
interface IProjectHelper {
projectDir: string;
generateDefaultAppId(appName: string, baseAppId: string): string;
sanitizeName(appName: string): string;
}

interface IPropertiesParser {
Expand Down
7 changes: 6 additions & 1 deletion project-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class ProjectHelper implements IProjectHelper {
}

public generateDefaultAppId(appName: string, baseAppId: string): string {
var sanitizedName = _.filter(appName.split(""), (c) => /[a-zA-Z0-9]/.test(c)).join("");
var sanitizedName = this.sanitizeName(appName);
if (sanitizedName) {
if (/^\d+$/.test(sanitizedName)) {
sanitizedName = "the" + sanitizedName;
Expand All @@ -50,5 +50,10 @@ export class ProjectHelper implements IProjectHelper {

return util.format("%s.%s", baseAppId, sanitizedName);
}

public sanitizeName(appName: string): string {
var sanitizedName = _.filter(appName.split(""), (c) => /[a-zA-Z0-9]/.test(c)).join("");
return sanitizedName;
}
}
$injector.register("projectHelper", ProjectHelper);