(filePath: string = getTuiConfigPath())
| 101 | } |
| 102 | |
| 103 | export async function loadTuiConfig(filePath: string = getTuiConfigPath()): Promise<TuiConfig> { |
| 104 | if (!existsSync(filePath)) { |
| 105 | await saveTuiConfig(DEFAULT_TUI_CONFIG, filePath); |
| 106 | return DEFAULT_TUI_CONFIG; |
| 107 | } |
| 108 | |
| 109 | try { |
| 110 | const text = await readFile(filePath, 'utf-8'); |
| 111 | return parseTuiConfig(text); |
| 112 | } catch { |
| 113 | throw new TuiConfigParseError(DEFAULT_TUI_CONFIG); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | export function parseTuiConfig(tomlText: string): TuiConfig { |
| 118 | if (tomlText.trim().length === 0) { |
no test coverage detected