Skip to content

Commit

Permalink
fix(node-localstorage): use native fs
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Jul 21, 2023
1 parent 985287b commit 143793e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 0 additions & 1 deletion packages/node-localstorage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 4 additions & 2 deletions packages/node-localstorage/src/index.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -20,7 +20,9 @@ export const kvsLocalStorage = async <Schema extends KvsLocalStorageSchema>(
): Promise<KvsStorage<Schema>> => {
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
Expand Down

0 comments on commit 143793e

Please sign in to comment.