Skip to content

Commit

Permalink
Use ts.readConfigFile and allow comments in JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
ypresto committed Mar 6, 2021
1 parent 6bbaa9e commit 6cb6a97
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dist/index.js

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ export class Doctor {
}

static fromConfigFile(configPath: string, ts: typeof _ts): Doctor {
const content = fs.readFileSync(configPath).toString();
const { config, error } = ts.readConfigFile(configPath, ts.sys.readFile);
if (error) {
throw new Error(`Error while reading ${configPath}: ` + ts.flattenDiagnosticMessageText(error.messageText, '\n'))
}
const parsed = ts.parseJsonConfigFileContent(
JSON.parse(content),
config,
ts.sys,
path.dirname(configPath)
);
Expand Down

0 comments on commit 6cb6a97

Please sign in to comment.