()
| 152 | * Returns {} on missing file or malformed JSON. |
| 153 | */ |
| 154 | export function loadConfig(): PlannotatorConfig { |
| 155 | try { |
| 156 | if (!existsSync(CONFIG_PATH)) return {}; |
| 157 | const raw = readFileSync(CONFIG_PATH, "utf-8"); |
| 158 | const parsed = JSON.parse(raw); |
| 159 | return typeof parsed === "object" && parsed !== null ? parsed : {}; |
| 160 | } catch (e) { |
| 161 | process.stderr.write(`[plannotator] Warning: failed to read config.json: ${e}\n`); |
| 162 | return {}; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * Save config by merging partial values into the existing file. |
no test coverage detected