Skip to content

Commit 32d1172

Browse files
Don't fail asset generation when project.json can't be parsed
1 parent b5d2fd6 commit 32d1172

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/assets.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,17 @@ function hasWebServerDependency(targetProjectData: TargetProjectData): boolean {
329329
let projectJson = fs.readFileSync(targetProjectData.projectJsonPath, 'utf8');
330330
projectJson = projectJson.replace(/^\uFEFF/, '');
331331

332-
let projectJsonObject = JSON.parse(projectJson);
333-
332+
let projectJsonObject: any;
333+
334+
try {
335+
// TODO: This error should be surfaced to the user. If the JSON can't be parsed
336+
// (maybe due to a syntax error like an extra comma), the user should be notified
337+
// to fix up their project.json.
338+
projectJsonObject = JSON.parse(projectJson);
339+
} catch (error) {
340+
projectJsonObject = null;
341+
}
342+
334343
if (projectJsonObject == null) {
335344
return false;
336345
}

0 commit comments

Comments
 (0)