(filePath: string)
| 49 | `; |
| 50 | |
| 51 | export async function ensureConfigFile(filePath: string): Promise<void> { |
| 52 | await mkdir(dirname(filePath), { recursive: true, mode: 0o700 }); |
| 53 | let handle: Awaited<ReturnType<typeof open>> | undefined; |
| 54 | try { |
| 55 | handle = await open(filePath, 'wx', 0o600); |
| 56 | await handle.writeFile(DEFAULT_CONFIG_FILE_TEXT, 'utf-8'); |
| 57 | } catch (error) { |
| 58 | if (isFileExistsError(error)) return; |
| 59 | throw error; |
| 60 | } finally { |
| 61 | await handle?.close(); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | export function readConfigFile(filePath: string): KimiConfig { |
| 66 | if (!existsSync(filePath)) { |
no test coverage detected