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