We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6d52028 commit 4b177a1Copy full SHA for 4b177a1
scripts/build/utils.mjs
@@ -72,12 +72,18 @@ export class ExecError extends Error {
72
}
73
74
/**
75
- * Reads JSON data with optional comments using the LKG TypeScript compiler
+ * Reads JSON data with optional comments
76
* @param {string} jsonPath
77
*/
78
export function readJson(jsonPath) {
79
const jsonText = fs.readFileSync(jsonPath, "utf8");
80
- return JSONC.parse(jsonText);
+ /** @type {JSONC.ParseError[]} */
81
+ const errors = [];
82
+ const result = JSONC.parse(jsonText, errors);
83
+ if (errors.length) {
84
+ throw new Error(`Error parsing ${jsonPath}`);
85
+ }
86
+ return result;
87
88
89
0 commit comments