| 23 | } |
| 24 | |
| 25 | export async function readSettings(): Promise<Settings> { |
| 26 | if (!existsSync(configuration.settingsFile)) { |
| 27 | return { ...defaultSettings } |
| 28 | } |
| 29 | try { |
| 30 | const content = await readFile(configuration.settingsFile, 'utf8') |
| 31 | const raw = JSON.parse(content) |
| 32 | return { ...defaultSettings, ...raw }; |
| 33 | } catch (error: any) { |
| 34 | logger.warn(`Failed to read settings: ${error.message}`); |
| 35 | return { ...defaultSettings } |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | export async function writeSettings(settings: Settings): Promise<void> { |
| 40 | if (!existsSync(configuration.consortiumHomeDir)) { |