@zenfs/core 1.1.2 → 1.1.3

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.
@@ -911,7 +911,13 @@ access;
911
911
  */
912
912
  export async function rm(path, options) {
913
913
  path = normalizePath(path);
914
- const stats = await stat(path);
914
+ const stats = await stat(path).catch((error) => {
915
+ if (error.code != 'ENOENT' || !options?.force)
916
+ throw error;
917
+ });
918
+ if (!stats) {
919
+ return;
920
+ }
915
921
  switch (stats.mode & constants.S_IFMT) {
916
922
  case constants.S_IFDIR:
917
923
  if (options?.recursive) {
@@ -613,7 +613,17 @@ accessSync;
613
613
  */
614
614
  export function rmSync(path, options) {
615
615
  path = normalizePath(path);
616
- const stats = statSync(path);
616
+ let stats;
617
+ try {
618
+ stats = statSync(path);
619
+ }
620
+ catch (error) {
621
+ if (error.code != 'ENOENT' || !options?.force)
622
+ throw error;
623
+ }
624
+ if (!stats) {
625
+ return;
626
+ }
617
627
  switch (stats.mode & constants.S_IFMT) {
618
628
  case constants.S_IFDIR:
619
629
  if (options?.recursive) {
package/dist/utils.d.ts CHANGED
@@ -17,8 +17,6 @@ export declare function mkdirpSync(path: string, mode: number, fs: FileSystem):
17
17
  * @hidden
18
18
  */
19
19
  export declare function levenshtein(a: string, b: string): number;
20
- /** @hidden */
21
- export declare const setImmediate: (callback: () => unknown) => void;
22
20
  /**
23
21
  * Encodes a string into a buffer
24
22
  * @internal
package/dist/utils.js CHANGED
@@ -83,8 +83,6 @@ export function levenshtein(a, b) {
83
83
  }
84
84
  return dd;
85
85
  }
86
- /** @hidden */
87
- export const setImmediate = typeof globalThis.setImmediate == 'function' ? globalThis.setImmediate : (cb) => setTimeout(cb, 0);
88
86
  /**
89
87
  * Encodes a string into a buffer
90
88
  * @internal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/core",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "A filesystem, anywhere",
5
5
  "funding": {
6
6
  "type": "individual",
@@ -938,7 +938,13 @@ access satisfies typeof promises.access;
938
938
  export async function rm(path: fs.PathLike, options?: fs.RmOptions) {
939
939
  path = normalizePath(path);
940
940
 
941
- const stats = await stat(path);
941
+ const stats = await stat(path).catch((error: ErrnoError) => {
942
+ if (error.code != 'ENOENT' || !options?.force) throw error;
943
+ });
944
+
945
+ if (!stats) {
946
+ return;
947
+ }
942
948
 
943
949
  switch (stats.mode & constants.S_IFMT) {
944
950
  case constants.S_IFDIR:
@@ -648,7 +648,16 @@ accessSync satisfies typeof fs.accessSync;
648
648
  export function rmSync(path: fs.PathLike, options?: fs.RmOptions): void {
649
649
  path = normalizePath(path);
650
650
 
651
- const stats = statSync(path);
651
+ let stats: Stats | undefined;
652
+ try {
653
+ stats = statSync(path);
654
+ } catch (error: any) {
655
+ if (error.code != 'ENOENT' || !options?.force) throw error;
656
+ }
657
+
658
+ if (!stats) {
659
+ return;
660
+ }
652
661
 
653
662
  switch (stats.mode & constants.S_IFMT) {
654
663
  case constants.S_IFDIR:
package/src/utils.ts CHANGED
@@ -10,10 +10,6 @@ declare global {
10
10
  function btoa(data: string): string;
11
11
  }
12
12
 
13
- declare const globalThis: {
14
- setImmediate?: (callback: () => unknown) => void;
15
- };
16
-
17
13
  /**
18
14
  * Synchronous recursive makedir.
19
15
  * @hidden
@@ -112,9 +108,6 @@ export function levenshtein(a: string, b: string): number {
112
108
  return dd;
113
109
  }
114
110
 
115
- /** @hidden */
116
- export const setImmediate = typeof globalThis.setImmediate == 'function' ? globalThis.setImmediate : (cb: () => unknown) => setTimeout(cb, 0);
117
-
118
111
  /**
119
112
  * Encodes a string into a buffer
120
113
  * @internal