(filePath: string, onError?: (error: string) => void)
| 17 | } |
| 18 | |
| 19 | export async function readOrCreateFile(filePath: string, onError?: (error: string) => void): Promise<AppConfigData> { |
| 20 | let error: Error | undefined; |
| 21 | let data: AppConfigData | undefined; |
| 22 | |
| 23 | try { |
| 24 | data = await readFile(filePath, onError); |
| 25 | } catch (e: any) { |
| 26 | error = e; |
| 27 | } |
| 28 | |
| 29 | if (error || !data) { |
| 30 | data = deepCopy(getDefaultConfigData(process.platform)); |
| 31 | saveFile(filePath, data).catch(() => console.log('Failed to save default config file!')); |
| 32 | } |
| 33 | |
| 34 | return data; |
| 35 | } |
| 36 | |
| 37 | export function readOrCreateFileSync(filePath: string, onError?: (error: string) => void): AppConfigData { |
| 38 | let error: Error | undefined; |
nothing calls this directly
no test coverage detected