(filePath)
| 107 | } |
| 108 | |
| 109 | export function readJsonFile(filePath) { |
| 110 | if (!fileExists(filePath)) { |
| 111 | return {}; |
| 112 | } |
| 113 | const content = fs.readFileSync(filePath, 'utf-8'); |
| 114 | try { |
| 115 | return JSON.parse(content); |
| 116 | } catch (e) { |
| 117 | console.error(`Error parsing JSON from ${filePath}: ${e.message}`); |
| 118 | return {}; |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | export function writeJsonFile(filePath, data) { |
| 123 | fs.writeFileSync(filePath, JSON.stringify(data, null, 2)); |
no test coverage detected