Skip to content

Commit 2a9870c

Browse files
Fix tns init command
When tns init command is called in empty directory, there's no project data and getting projectName from projectId is failing.
1 parent 2f24064 commit 2a9870c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/services/android-project-service.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
149149
}
150150

151151
private getProjectNameFromId(): string {
152-
return this.$projectData.projectId.split(".")[2];
152+
let id: string;
153+
if(this.$projectData && this.$projectData.projectId) {
154+
id = this.$projectData.projectId.split(".")[2];
155+
}
156+
157+
return id;
153158
}
154159

155160
public afterCreateProject(projectRoot: string): IFuture<void> {

0 commit comments

Comments
 (0)