()
| 533 | const WATCH_DEBOUNCE_MS = 150 |
| 534 | |
| 535 | async function readConfigFile(): Promise<{ text: string; portable: AppConfigPortable } | null> { |
| 536 | const file = getConfigFilePath() |
| 537 | let text: string |
| 538 | try { |
| 539 | text = await fs.readFile(file, 'utf8') |
| 540 | } catch (err) { |
| 541 | if (isMissingFileError(err)) return null |
| 542 | console.warn('Failed to read config.toml', err) |
| 543 | return null |
| 544 | } |
| 545 | try { |
| 546 | const { portable } = deserializeConfig(text) |
| 547 | return { text, portable } |
| 548 | } catch (err) { |
| 549 | console.warn('Failed to parse config.toml — keeping last good config', err) |
| 550 | return null |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | function debounce<Args extends unknown[]>( |
| 555 | fn: (...args: Args) => void, |
no test coverage detected