Skip to content

Catch invalid project file and gives an helpful message to the user #141

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
Nov 5, 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
9 changes: 9 additions & 0 deletions lib/project-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"use strict";

import path = require("path");
import os = require("os");

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

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