From 23c0647e6cf8f1bfb67912ceb60b2a5c69c7b637 Mon Sep 17 00:00:00 2001 From: V Date: Wed, 21 Jun 2023 17:24:50 +0200 Subject: [PATCH] Fix ENOENT on first install --- src/main/settings.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/settings.ts b/src/main/settings.ts index 3061509..dfb7474 100644 --- a/src/main/settings.ts +++ b/src/main/settings.ts @@ -4,8 +4,8 @@ * Copyright (c) 2023 Vendicated and Vencord contributors */ -import { readFileSync, writeFileSync } from "fs"; -import { join } from "path"; +import { mkdirSync, readFileSync, writeFileSync } from "fs"; +import { dirname, join } from "path"; import type { Settings as TSettings } from "shared/settings"; import { SettingsStore } from "shared/utils/SettingsStore"; @@ -25,7 +25,10 @@ function loadSettings(file: string, name: string) { } catch {} const store = new SettingsStore(settings); - store.addGlobalChangeListener(o => writeFileSync(file, JSON.stringify(o, null, 4))); + store.addGlobalChangeListener(o => { + mkdirSync(dirname(file), { recursive: true }); + writeFileSync(file, JSON.stringify(o, null, 4)); + }); return store; }