(path: string)
| 194 | * @returns The parsed JSON object. |
| 195 | */ |
| 196 | export function readAndParseJson<T extends JsonValue>(path: string): T { |
| 197 | const errors: ParseError[] = []; |
| 198 | const content = parse(readFileSync(path, 'utf-8'), errors, { allowTrailingComma: true }) as T; |
| 199 | if (errors.length) { |
| 200 | formatError(path, errors); |
| 201 | } |
| 202 | |
| 203 | return content; |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * Formats a JSON parsing error and throws an exception. |
no test coverage detected