(filePath: string)
| 89 | } |
| 90 | |
| 91 | function readJsonFile<T>(filePath: string): T { |
| 92 | try { |
| 93 | return JSON.parse(readFileSync(filePath, "utf8")) as T; |
| 94 | } catch (error) { |
| 95 | const reason = error instanceof Error ? error.message : String(error); |
| 96 | throw new Error(`Unable to read ${filePath}: ${reason}`); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | function writeJsonFile(filePath: string, value: unknown, mode: number): void { |
| 101 | writeFileSync(filePath, JSON.stringify(value, null, 2) + "\n", { mode }); |