chore(tsconfig): abort on invalid json content (#3578)

Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
This commit is contained in:
Chengzhong Wu 2023-02-01 04:11:08 +08:00 committed by GitHub
parent 2a76d881e4
commit 2b59c2820c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 11 deletions

View File

@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.es5.json",
"extends": "../../../tsconfig.base.es5.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "build"

View File

@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.es5.json",
"extends": "../../../tsconfig.base.es5.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "build"

View File

@ -6,6 +6,7 @@
},
"include": [
"src/**/*.ts",
"src/generated/*.js",
"test/**/*.ts"
],
"references": [

View File

@ -247,12 +247,7 @@ function resolvePackageMeta(pkgDir) {
}
function readAndMaybeMergeTsConfig(tsconfigPath, updates) {
let tsconfig;
try {
tsconfig = readJSON(tsconfigPath);
} catch {
return updates;
}
const tsconfig = readJSON(tsconfigPath);
updates = mergeTsConfig(tsconfig, updates);
return updates;
}
@ -284,8 +279,11 @@ function hasEsTargets(pjson) {
function readJSON(filepath) {
const fileContent = fs.readFileSync(filepath, 'utf8');
const json = JSON.parse(fileContent);
return json;
try {
return JSON.parse(fileContent);
} catch (e) {
throw new Error(`Invalid JSON ${filepath}: ${e.message}`);
}
}
function writeJSON(filepath, content, dry) {

View File

@ -1,5 +1,5 @@
{
"extends": "./tsconfig.es5.json",
"extends": "./tsconfig.base.es5.json",
"compilerOptions": {
"module": "ES6",
"moduleResolution": "node"