handle potential filesystem errors when saving settings
This commit is contained in:
@@ -27,8 +27,12 @@ function loadSettings<T extends object = any>(file: string, name: string) {
|
||||
|
||||
const store = new SettingsStore(settings);
|
||||
store.addGlobalChangeListener(o => {
|
||||
try {
|
||||
mkdirSync(dirname(file), { recursive: true });
|
||||
writeFileSync(file, JSON.stringify(o, null, 4));
|
||||
} catch (err) {
|
||||
console.error(`Failed to save settings to ${name}.json:`, err);
|
||||
}
|
||||
});
|
||||
|
||||
return store;
|
||||
|
||||
Reference in New Issue
Block a user