From 46a2c9d472f70eabe4ccc1c3938d54a2e5ae38c0 Mon Sep 17 00:00:00 2001 From: azu Date: Fri, 21 Jul 2023 21:19:23 +0900 Subject: [PATCH] fix(node-localstorage): use native fs (#44) --- packages/node-localstorage/package.json | 1 - packages/node-localstorage/src/index.ts | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/node-localstorage/package.json b/packages/node-localstorage/package.json index c849af8..30cf528 100644 --- a/packages/node-localstorage/package.json +++ b/packages/node-localstorage/package.json @@ -47,7 +47,6 @@ "dependencies": { "@kvs/storage": "^2.1.4", "app-root-path": "^3.1.0", - "mkdirp": "^3.0.1", "node-localstorage": "^2.1.6" }, "devDependencies": { diff --git a/packages/node-localstorage/src/index.ts b/packages/node-localstorage/src/index.ts index fb2cc91..0f3355c 100644 --- a/packages/node-localstorage/src/index.ts +++ b/packages/node-localstorage/src/index.ts @@ -1,11 +1,11 @@ import path from "path"; import { JsonValue, KvsStorage, kvsStorage } from "@kvs/storage"; import { KVS, KVSOptions } from "@kvs/types"; +import fs from "node:fs/promises"; // @ts-ignore import { LocalStorage } from "node-localstorage"; // @ts-ignore import appRoot from "app-root-path"; -import { mkdirp } from "mkdirp"; export type KvsLocalStorageSchema = { [index: string]: JsonValue; @@ -20,7 +20,9 @@ export const kvsLocalStorage = async ( ): Promise> => { const defaultCacheDir = path.join(appRoot.toString(), ".cache"); if (!options.storeFilePath) { - await mkdirp(defaultCacheDir); + await fs.mkdir(defaultCacheDir, { + recursive: true + }); } const saveFilePath = options.storeFilePath ? options.storeFilePath