chore(tsconfig): abort on invalid json content (#3578)
Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
This commit is contained in:
parent
2a76d881e4
commit
2b59c2820c
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"extends": "../../../tsconfig.es5.json",
|
||||
"extends": "../../../tsconfig.base.es5.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": ".",
|
||||
"outDir": "build"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"extends": "../../../tsconfig.es5.json",
|
||||
"extends": "../../../tsconfig.base.es5.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": ".",
|
||||
"outDir": "build"
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/generated/*.js",
|
||||
"test/**/*.ts"
|
||||
],
|
||||
"references": [
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"extends": "./tsconfig.es5.json",
|
||||
"extends": "./tsconfig.base.es5.json",
|
||||
"compilerOptions": {
|
||||
"module": "ES6",
|
||||
"moduleResolution": "node"
|
||||
|
|
Loading…
Reference in New Issue