Create settings file if it does not exist

Fixes #22
This commit is contained in:
Stubenhocker1399
2019-08-29 23:41:39 +02:00
parent 735845746e
commit eab78e2100
+5
View File
@@ -14,8 +14,13 @@ const settingsPath = paths.pathTo('settings', `settings.json`);
/* istanbul ignore next */
export async function loadSettings() {
try {
const json = await readFileAsync(settingsPath, 'utf8');
return JSON.parse(json) as Settings;
} catch (e) {
writeFileAsync(settingsPath, '{}', 'utf8');
return {} as Settings;
}
}
/* istanbul ignore next */