Only create new settings file if file is missing

This commit is contained in:
Stubenhocker1399
2019-08-30 00:46:27 +02:00
parent eab78e2100
commit f2e953f8cf
+7 -2
View File
@@ -18,8 +18,13 @@ export async function loadSettings() {
const json = await readFileAsync(settingsPath, 'utf8'); const json = await readFileAsync(settingsPath, 'utf8');
return JSON.parse(json) as Settings; return JSON.parse(json) as Settings;
} catch (e) { } catch (e) {
writeFileAsync(settingsPath, '{}', 'utf8'); if (e === 'ENOENT') {
return {} as Settings; writeFileAsync(settingsPath, '{}', 'utf8');
return {} as Settings;
} else {
console.log("Error reading settings file: " + e);
return {} as Settings;
}
} }
} }