()
| 7 | import type { GlobalFlags } from '../types/flags'; |
| 8 | |
| 9 | export function readConfigFile(): ConfigFile { |
| 10 | const path = getConfigPath(); |
| 11 | if (!existsSync(path)) return {}; |
| 12 | try { |
| 13 | return parseConfigFile(JSON.parse(readFileSync(path, 'utf-8'))); |
| 14 | } catch (err) { |
| 15 | const e = err as Error; |
| 16 | if (e instanceof SyntaxError || e.message.includes('JSON')) { |
| 17 | process.stderr.write(`Warning: config file is corrupted. Run 'mmx config set' to reset.\n`); |
| 18 | } |
| 19 | return {}; |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | export async function writeConfigFile(data: Record<string, unknown>): Promise<void> { |
| 24 | await ensureConfigDir(); |
no test coverage detected