Skip to content

Commit

Permalink
fix(@angular/cli): allow trailing commas in JSON files
Browse files Browse the repository at this point in the history
Currently, both tsconfigs and workspace configuration files can contain trailing commas

Closes #19576
  • Loading branch information
alan-agius4 authored and clydin committed Dec 9, 2020
1 parent 07e3766 commit d368bfd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/angular/cli/utilities/json-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class JSONFile {
}

const errors: ParseError[] = [];
this._jsonAst = parseTree(this.content, errors);
this._jsonAst = parseTree(this.content, errors, { allowTrailingComma: true });
if (errors.length) {
formatError(this.path, errors);
}
Expand Down Expand Up @@ -106,7 +106,7 @@ export class JSONFile {
// tslint:disable-next-line: no-any
export function readAndParseJson(path: string): any {
const errors: ParseError[] = [];
const content = parse(readFileSync(path, 'utf-8'), errors);
const content = parse(readFileSync(path, 'utf-8'), errors, { allowTrailingComma: true });
if (errors.length) {
formatError(path, errors);
}
Expand All @@ -121,5 +121,5 @@ function formatError(path: string, errors: ParseError[]): never {

// tslint:disable-next-line: no-any
export function parseJson(content: string): any {
return parse(content);
return parse(content, undefined, { allowTrailingComma: true });
}

0 comments on commit d368bfd

Please sign in to comment.