(filePath: string, onError?: (error: string) => void)
| 35 | } |
| 36 | |
| 37 | export function readOrCreateFileSync(filePath: string, onError?: (error: string) => void): AppConfigData { |
| 38 | let error: Error | undefined; |
| 39 | let data: AppConfigData | undefined; |
| 40 | |
| 41 | try { |
| 42 | data = readFileSync(filePath, onError); |
| 43 | } catch (e: any) { |
| 44 | error = e; |
| 45 | } |
| 46 | |
| 47 | if (error || !data) { |
| 48 | data = deepCopy(getDefaultConfigData(process.platform)); |
| 49 | saveFile(filePath, data).catch(() => console.log('Failed to save default config file!')); |
| 50 | } |
| 51 | |
| 52 | return data; |
| 53 | } |
| 54 | |
| 55 | export function saveFile(filePath: string, data: AppConfigData): Promise<void> { |
| 56 | return new Promise((resolve, reject) => { |
nothing calls this directly
no test coverage detected