Skip to content
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

Fix error when tsconfig.json contains comment #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Use ts.readConfigFile and allow comments in JSON
ypresto committed Mar 6, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 6cb6a970f0783c19f55fb83079f7846a583c7543
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
@@ -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)
);