(filePath)
| 95 | } |
| 96 | |
| 97 | export function readJsonFile(filePath) { |
| 98 | if (!fileExists(filePath)) { |
| 99 | return {}; |
| 100 | } |
| 101 | const content = fs.readFileSync(filePath, 'utf-8'); |
| 102 | try { |
| 103 | return JSON.parse(content); |
| 104 | } catch (e) { |
| 105 | console.error(`Error parsing JSON from ${filePath}: ${e.message}`); |
| 106 | return {}; |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | export function writeJsonFile(filePath, data) { |
| 111 | fs.writeFileSync(filePath, JSON.stringify(data, null, 2)); |
no test coverage detected