Skip to content

Commit 56fef1d

Browse files
committed
Merge pull request #141 from NativeScript/totev/broken-abproject
Catch invalid project file and gives an helpful message to the user
2 parents 5eda9d5 + 8b5af35 commit 56fef1d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/project-data.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"use strict";
33

44
import path = require("path");
5+
import os = require("os");
56

67
export class ProjectData implements IProjectData {
78
public projectDir: string;
@@ -28,8 +29,16 @@ export class ProjectData implements IProjectData {
2829
this.projectFilePath = path.join(projectDir, this.$staticConfig.PROJECT_FILE_NAME);
2930

3031
if (this.$fs.exists(this.projectFilePath).wait()) {
32+
try {
3133
var fileContent = this.$fs.readJson(this.projectFilePath).wait();
3234
this.projectId = fileContent.id;
35+
} catch (err) {
36+
this.$errors.fail({formatStr: "The project file %s is corrupted." + os.EOL +
37+
"Consider restoring an earlier version from your source control or backup." + os.EOL +
38+
"Additional technical info: %s",
39+
suppressCommandHelp: true},
40+
this.projectFilePath, err.toString());
41+
}
3342
}
3443
} else {
3544
this.$errors.fail("No project found at or above '%s' and neither was a --path specified.", process.cwd());

0 commit comments

Comments
 (0)