(filePath: string)
| 88 | * only where one is actually about to be overwritten. |
| 89 | */ |
| 90 | export function readJsonFile(filePath: string): Record<string, any> { |
| 91 | if (!fs.existsSync(filePath)) { |
| 92 | return {}; |
| 93 | } |
| 94 | try { |
| 95 | return JSON.parse(fs.readFileSync(filePath, 'utf-8')); |
| 96 | } catch { |
| 97 | return {}; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Write a file atomically: write to `<path>.tmp.<pid>`, then rename. |
no test coverage detected