@wxn0brp/db-storage-dir 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/action.js CHANGED
@@ -4,6 +4,7 @@ import { findUtil } from "@wxn0brp/db-core/utils/action";
4
4
  import { promises } from "fs";
5
5
  import { resolve, sep } from "path";
6
6
  import { FileActionsUtils } from "./action.utils.js";
7
+ import { exists } from "./utils.js";
7
8
  /**
8
9
  * A class representing database actions on files.
9
10
  * @class
@@ -33,7 +34,7 @@ export class FileActions extends ActionsBase {
33
34
  };
34
35
  }
35
36
  async init() {
36
- if (!await promises.exists(this.folder))
37
+ if (!await exists(this.folder))
37
38
  await promises.mkdir(this.folder, { recursive: true });
38
39
  }
39
40
  _getCollectionPath(collection) {
@@ -1,4 +1,5 @@
1
- import { exists, mkdir, readdir, stat, writeFile } from "fs/promises";
1
+ import { mkdir, readdir, stat, writeFile } from "fs/promises";
2
+ import { exists } from "./utils.js";
2
3
  export class FileActionsUtils {
3
4
  /**
4
5
  * Get the last file in the specified directory.
@@ -0,0 +1 @@
1
+ export declare function exists(path: string): Promise<boolean>;
package/dist/utils.js ADDED
@@ -0,0 +1,10 @@
1
+ import { access } from "node:fs/promises";
2
+ export async function exists(path) {
3
+ try {
4
+ await access(path);
5
+ return true;
6
+ }
7
+ catch {
8
+ return false;
9
+ }
10
+ }
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = "0.2.4";
1
+ export const version = "0.2.5";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wxn0brp/db-storage-dir",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "wxn0brP",