config: handle config deleted

Revert to defaults if config file moved/deleted
This commit is contained in:
2 * r + 2 * t 2025-04-07 14:58:58 +10:00
parent 4a1a3a6d89
commit 5d5bea5758

View file

@ -100,7 +100,9 @@ const updateSection = (from: { [k: string]: any }, to: { [k: string]: any }, pat
};
export const updateConfig = async () => {
updateSection(deepMerge(defaults, JSON.parse(await readFileAsync(CONFIG))), config);
if (GLib.file_test(CONFIG, GLib.FileTest.EXISTS))
updateSection(deepMerge(defaults, JSON.parse(await readFileAsync(CONFIG))), config);
else updateSection(defaults, config);
await loadStyleAsync();
console.log("[LOG] Config updated");
};