(path, label)
| 59 | } |
| 60 | |
| 61 | function readJson(path, label) { |
| 62 | let raw = ""; |
| 63 | try { |
| 64 | raw = readFileSync(path, "utf8"); |
| 65 | } catch (error) { |
| 66 | fail( |
| 67 | `${label}: failed to read ${path}: ${error instanceof Error ? error.message : String(error)}`, |
| 68 | ); |
| 69 | } |
| 70 | |
| 71 | let parsed; |
| 72 | try { |
| 73 | parsed = JSON.parse(raw); |
| 74 | } catch (error) { |
| 75 | fail( |
| 76 | `${label}: failed to parse ${path}: ${error instanceof Error ? error.message : String(error)}`, |
| 77 | ); |
| 78 | } |
| 79 | return parsed; |
| 80 | } |
| 81 | |
| 82 | function isPlainObject(value) { |
| 83 | return value !== null && typeof value === "object" && !Array.isArray(value); |
no test coverage detected