From b4e409f5c6f781a78737ba7b13d57441a874459c Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sat, 7 Aug 2021 18:52:22 +0200 Subject: :bug: fix file storage dir --- src/util/FileStorage.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/util/FileStorage.ts') diff --git a/src/util/FileStorage.ts b/src/util/FileStorage.ts index 4a449d5a..453133f3 100644 --- a/src/util/FileStorage.ts +++ b/src/util/FileStorage.ts @@ -1,6 +1,7 @@ import { Storage } from "./Storage"; import fs from "fs"; -import { join, relative } from "path"; +import fse from "fs-extra"; +import { join, relative, dirname } from "path"; import "missing-native-js-functions"; function getPath(path: string) { @@ -23,8 +24,7 @@ export class FileStorage implements Storage { async set(path: string, value: any) { path = getPath(path); - const dir = path.split("/").slice(0, -1).join("/"); - fs.mkdirSync(dir, { recursive: true }); + fse.ensureDirSync(dirname(path)); return fs.writeFileSync(path, value, { encoding: "binary" }); } -- cgit 1.5.1