(filePath: string)
| 36 | } |
| 37 | |
| 38 | function readConfig(filePath: string): JsonObject | null { |
| 39 | if (!existsSync(filePath)) { |
| 40 | return null; |
| 41 | } |
| 42 | |
| 43 | try { |
| 44 | const parsed = parse(readFileSync(filePath, "utf-8")); |
| 45 | return isRecord(parsed) ? parsed : null; |
| 46 | } catch { |
| 47 | return null; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | function writeConfig(filePath: string, config: JsonObject): void { |
| 52 | writeFileSync(filePath, `${stringify(config, null, 2)}\n`); |
no test coverage detected