summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/util/AutoUpdate.ts2
-rw-r--r--src/util/util/Config.ts12
2 files changed, 9 insertions, 5 deletions
diff --git a/src/util/util/AutoUpdate.ts b/src/util/util/AutoUpdate.ts

index 769d959f..6fbad63e 100644 --- a/src/util/util/AutoUpdate.ts +++ b/src/util/util/AutoUpdate.ts
@@ -60,7 +60,7 @@ async function download(url: string, dir: string) { const response = await fetch(url, { agent }); const buffer = await response.buffer(); const tempDir = await fs.mkdtemp("fosscord"); - fs.writeFile(path.join(tempDir, "Fosscord.zip"), buffer); + await fs.writeFile(path.join(tempDir, "Fosscord.zip"), buffer); } catch (error) { console.error(`[Auto Update] download failed`, error); } diff --git a/src/util/util/Config.ts b/src/util/util/Config.ts
index 5d98f5bc..149f3746 100644 --- a/src/util/util/Config.ts +++ b/src/util/util/Config.ts
@@ -1,5 +1,6 @@ import { ConfigEntity } from "../entities/Config"; -import fs from "fs"; +import fs from "fs/promises"; +import syncFs from "fs"; import { ConfigValue } from "../config"; // TODO: yaml instead of json @@ -31,11 +32,14 @@ export const Config = { ); try { const overrideConfig = JSON.parse( - fs.readFileSync(overridePath, { encoding: "utf8" }), + await fs.readFile(overridePath, { encoding: "utf8" }), ); config = overrideConfig.merge(config); } catch (error) { - fs.writeFileSync(overridePath, JSON.stringify(config, null, 4)); + await fs.writeFile( + overridePath, + JSON.stringify(config, null, 4), + ); } } @@ -79,7 +83,7 @@ function applyConfig(val: ConfigValue) { } if (process.env.CONFIG_PATH) - fs.writeFileSync(overridePath, JSON.stringify(val, null, 4)); + syncFs.writeFileSync(overridePath, JSON.stringify(val, null, 4)); return apply(val); }