@visulima/fs 5.0.10 → 5.0.11

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.
Files changed (132) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/eol.d.ts +25 -25
  3. package/dist/eol.js +2 -2
  4. package/dist/error.d.ts +218 -218
  5. package/dist/glob-parent.d.ts +27 -27
  6. package/dist/glob-parent.js +1 -1
  7. package/dist/glob.d.ts +2 -2
  8. package/dist/glob.js +1 -1
  9. package/dist/index.d.ts +765 -765
  10. package/dist/index.js +1 -1
  11. package/dist/ini.d.ts +59 -59
  12. package/dist/ini.js +1 -1
  13. package/dist/is-glob.d.ts +26 -26
  14. package/dist/json5.d.ts +25 -25
  15. package/dist/json5.js +1 -1
  16. package/dist/jsonc.d.ts +54 -54
  17. package/dist/jsonc.js +1 -1
  18. package/dist/match.d.ts +40 -40
  19. package/dist/packem_shared/{collect-CIKDOMiD.js → collect-B0S0bJoE.js} +1 -1
  20. package/dist/packem_shared/{collectSync-D0FRLLqg.js → collectSync-0M1eoilI.js} +1 -1
  21. package/dist/packem_shared/copy-DiR5_5iA.js +1 -0
  22. package/dist/packem_shared/copySync-DffsYlhb.js +1 -0
  23. package/dist/packem_shared/emptyDir-BlBeczk0.js +1 -0
  24. package/dist/packem_shared/emptyDirSync-DfUZ9Ejz.js +1 -0
  25. package/dist/packem_shared/ensureDir-BEiomfxz.js +1 -0
  26. package/dist/packem_shared/ensureDirSync-B0w9WMwE.js +1 -0
  27. package/dist/packem_shared/ensureFile-waD4hDO8.js +1 -0
  28. package/dist/packem_shared/ensureFileSync-CG07zjV7.js +1 -0
  29. package/dist/packem_shared/ensureLink-Dz-PDWa5.js +1 -0
  30. package/dist/packem_shared/ensureLinkSync-BZH7TaSQ.js +1 -0
  31. package/dist/packem_shared/ensureSymlink-Byi6ajoE.js +1 -0
  32. package/dist/packem_shared/ensureSymlinkSync-D7OCsAd8.js +1 -0
  33. package/dist/packem_shared/findUp-Ylerv_a2.js +1 -0
  34. package/dist/packem_shared/findUpSync-BWBPRzEq.js +1 -0
  35. package/dist/packem_shared/glob-BUjyjdE8.js +1 -0
  36. package/dist/packem_shared/glob-sync.d-DaAZHTsv.d.ts +54 -0
  37. package/dist/packem_shared/globSync-Bk9TUV7x.js +1 -0
  38. package/dist/packem_shared/index-CPZbuHkp.js +1 -0
  39. package/dist/packem_shared/isAccessible-B7guOm3k.js +1 -0
  40. package/dist/packem_shared/isAccessibleSync-XH4YleJW.js +1 -0
  41. package/dist/packem_shared/json-error.d-COL8oxF_.d.ts +52 -0
  42. package/dist/packem_shared/move-KhPRvsRd.js +1 -0
  43. package/dist/packem_shared/{parseJson-EASgP4J9.js → parseJson-_OfIPruP.js} +1 -1
  44. package/dist/packem_shared/readFile-VgxUDrNH.js +1 -0
  45. package/dist/packem_shared/readFileSync-CloFeQw8.js +1 -0
  46. package/dist/packem_shared/{readIni-BsXudu2r.js → readIni-CEXHWn92.js} +1 -1
  47. package/dist/packem_shared/readIniSync-DsxVHypc.js +1 -0
  48. package/dist/packem_shared/{readJson-CcAsHxE5.js → readJson-Q3T3RlSy.js} +1 -1
  49. package/dist/packem_shared/{readJson5-CM1TIiHd.js → readJson5-S68aVros.js} +1 -1
  50. package/dist/packem_shared/{readJson5Sync-Bc26c3Fy.js → readJson5Sync-Bi9Rv46R.js} +1 -1
  51. package/dist/packem_shared/{readJsonSync-DuMMeB3s.js → readJsonSync-BnWiH5-R.js} +1 -1
  52. package/dist/packem_shared/{readJsonc-BZjMw_0f.js → readJsonc-DSoFyuDk.js} +1 -1
  53. package/dist/packem_shared/{readJsoncSync-C-xzeZz4.js → readJsoncSync-CLtlvFKV.js} +1 -1
  54. package/dist/packem_shared/readToml-CN_xnICv.js +1 -0
  55. package/dist/packem_shared/readTomlSync-B9TVGzen.js +1 -0
  56. package/dist/packem_shared/{readYaml-DvPxndW_.js → readYaml-DcpUq11D.js} +1 -1
  57. package/dist/packem_shared/{readYamlSync-DZ-0hSbZ.js → readYamlSync-D5RVZwco.js} +1 -1
  58. package/dist/packem_shared/remove-D_CUIlBL.js +1 -0
  59. package/dist/packem_shared/removeSync-F4nKiwrU.js +1 -0
  60. package/dist/packem_shared/renderError-DjesnVYT-pWsLqw-_.js +6 -0
  61. package/dist/packem_shared/sanitize-aEqeyx4d.js +1 -0
  62. package/dist/packem_shared/to-uint-8-array-7sXMoZwU.js +1 -0
  63. package/dist/packem_shared/{types.d-BMdL_ygj.d.ts → types.d-D3Jo_iA-.d.ts} +361 -383
  64. package/dist/packem_shared/walk-BReeHTKb.js +1 -0
  65. package/dist/packem_shared/walkSync-yHJUIJb9.js +1 -0
  66. package/dist/packem_shared/writeFile-srDcYaRC.js +1 -0
  67. package/dist/packem_shared/writeFileSync-Ddl_u4my.js +1 -0
  68. package/dist/packem_shared/writeIni-CKinbquM.js +4 -0
  69. package/dist/packem_shared/writeIniSync-BISRFyg0.js +4 -0
  70. package/dist/packem_shared/writeJson-DlCrFMXb.js +4 -0
  71. package/dist/packem_shared/writeJson5-rSp3QAKP.js +4 -0
  72. package/dist/packem_shared/writeJson5Sync-tSBBKnaP.js +4 -0
  73. package/dist/packem_shared/writeJsonSync-CKqVRz_9.js +4 -0
  74. package/dist/packem_shared/writeJsonc-bxz1jdeU.js +4 -0
  75. package/dist/packem_shared/writeJsoncSync-C-W0H9qP.js +4 -0
  76. package/dist/packem_shared/{writeToml-IuMO-yDu.js → writeToml-CrpfWNyK.js} +1 -1
  77. package/dist/packem_shared/{writeTomlSync-DhL7hHzB.js → writeTomlSync-DveRchLG.js} +1 -1
  78. package/dist/packem_shared/{writeYaml-ClQgvQID.js → writeYaml-DvSQ_Jbn.js} +1 -1
  79. package/dist/packem_shared/{writeYamlSync-DrXtHQQq.js → writeYamlSync-CEf0PUGQ.js} +1 -1
  80. package/dist/size.d.ts +236 -236
  81. package/dist/size.js +1 -1
  82. package/dist/toml.d.ts +52 -52
  83. package/dist/toml.js +1 -1
  84. package/dist/utils.d.ts +88 -88
  85. package/dist/utils.js +1 -1
  86. package/dist/yaml.d.ts +2 -2
  87. package/dist/yaml.js +1 -1
  88. package/package.json +1 -1
  89. package/dist/packem_shared/copy-Beb64BYG.js +0 -1
  90. package/dist/packem_shared/copySync-CagcIEBi.js +0 -1
  91. package/dist/packem_shared/emptyDir-C7lyd1lW.js +0 -1
  92. package/dist/packem_shared/emptyDirSync-B8EYpmO9.js +0 -1
  93. package/dist/packem_shared/ensureDir-DGarVZw8.js +0 -1
  94. package/dist/packem_shared/ensureDirSync-CsgPrsDH.js +0 -1
  95. package/dist/packem_shared/ensureFile-CMugWljp.js +0 -1
  96. package/dist/packem_shared/ensureFileSync-CJYTEx2r.js +0 -1
  97. package/dist/packem_shared/ensureLink-ChShf3lf.js +0 -1
  98. package/dist/packem_shared/ensureLinkSync-DPpq0I2Z.js +0 -1
  99. package/dist/packem_shared/ensureSymlink-y4FZjfxA.js +0 -1
  100. package/dist/packem_shared/ensureSymlinkSync-TcHssCH7.js +0 -1
  101. package/dist/packem_shared/findUp-Cii5ATt5.js +0 -1
  102. package/dist/packem_shared/findUpSync-C9Lkh7-v.js +0 -1
  103. package/dist/packem_shared/glob-DMbPwGSj.js +0 -1
  104. package/dist/packem_shared/glob-sync.d-hXe38TnZ.d.ts +0 -54
  105. package/dist/packem_shared/globSync-DiP2rtGn.js +0 -1
  106. package/dist/packem_shared/index-Ct4GqZSP.js +0 -1
  107. package/dist/packem_shared/isAccessible-PmWJhV6I.js +0 -1
  108. package/dist/packem_shared/isAccessibleSync-BrbOtwdr.js +0 -1
  109. package/dist/packem_shared/json-error.d-DVILOyHc.d.ts +0 -52
  110. package/dist/packem_shared/move-DopmzT-2.js +0 -1
  111. package/dist/packem_shared/readFile-BswaBgM0.js +0 -1
  112. package/dist/packem_shared/readFileSync-_fDF6Oj1.js +0 -1
  113. package/dist/packem_shared/readIniSync-DKwRbbs9.js +0 -1
  114. package/dist/packem_shared/readToml-D4jpe9q_.js +0 -1
  115. package/dist/packem_shared/readTomlSync-B5PIYT9z.js +0 -1
  116. package/dist/packem_shared/remove-CSbrd0dl.js +0 -1
  117. package/dist/packem_shared/removeSync-BoLAzRQE.js +0 -1
  118. package/dist/packem_shared/renderError-B3ePOoBG-Bi9WKMjv.js +0 -6
  119. package/dist/packem_shared/sanitize-DGZ3w-_w.js +0 -1
  120. package/dist/packem_shared/to-uint-8-array-BImOQNXm.js +0 -1
  121. package/dist/packem_shared/walk-OX4-6oCP.js +0 -1
  122. package/dist/packem_shared/walkSync-BPs6czIM.js +0 -1
  123. package/dist/packem_shared/writeFile-BrMtsJY7.js +0 -1
  124. package/dist/packem_shared/writeFileSync-W7Mf4BNy.js +0 -1
  125. package/dist/packem_shared/writeIni-BWX3cP1K.js +0 -4
  126. package/dist/packem_shared/writeIniSync-fOdgPFfL.js +0 -4
  127. package/dist/packem_shared/writeJson-bEVi25gX.js +0 -4
  128. package/dist/packem_shared/writeJson5-Ch8TpNPI.js +0 -4
  129. package/dist/packem_shared/writeJson5Sync-BrctV_Mk.js +0 -4
  130. package/dist/packem_shared/writeJsonSync-DkGnd416.js +0 -4
  131. package/dist/packem_shared/writeJsonc-CefrwsOc.js +0 -4
  132. package/dist/packem_shared/writeJsoncSync-BskDjn8o.js +0 -4
package/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ ## @visulima/fs [5.0.11](https://github.com/visulima/visulima/compare/%40visulima%2Ffs%405.0.10...%40visulima%2Ffs%405.0.11) (2026-07-27)
2
+
1
3
  ## @visulima/fs [5.0.10](https://github.com/visulima/visulima/compare/%40visulima%2Ffs%405.0.9...%40visulima%2Ffs%405.0.10) (2026-07-27)
2
4
 
3
5
  ## @visulima/fs [5.0.9](https://github.com/visulima/visulima/compare/%40visulima%2Ffs%405.0.8...%40visulima%2Ffs%405.0.9) (2026-07-27)
package/dist/eol.d.ts CHANGED
@@ -3,34 +3,34 @@ declare const LF: "\n";
3
3
  /** End-of-line character for Windows platforms. */
4
4
  declare const CRLF: "\r\n";
5
5
  /**
6
- * End-of-line character evaluated for the current platform.
7
- */
6
+ * End-of-line character evaluated for the current platform.
7
+ */
8
8
  declare const EOL: "\n" | "\r\n";
9
9
  /**
10
- * Detect the EOL character for string input.
11
- * Returns null if no newline.
12
- * @param content The string content to detect the EOL from.
13
- * @example
14
- * ```javascript
15
- * import { detect } from "@visulima/fs/eol";
16
- *
17
- * detect("Hello\r\nWorld"); // "\r\n"
18
- * detect("Hello\nWorld"); // "\n"
19
- * detect("HelloWorld"); // null
20
- * ```
21
- */
10
+ * Detect the EOL character for string input.
11
+ * Returns null if no newline.
12
+ * @param content The string content to detect the EOL from.
13
+ * @example
14
+ * ```javascript
15
+ * import { detect } from "@visulima/fs/eol";
16
+ *
17
+ * detect("Hello\r\nWorld"); // "\r\n"
18
+ * detect("Hello\nWorld"); // "\n"
19
+ * detect("HelloWorld"); // null
20
+ * ```
21
+ */
22
22
  declare const detect: (content: string) => typeof EOL | null;
23
23
  /**
24
- * Format the file to the targeted EOL.
25
- * @param content The string content to format.
26
- * @param eol The target EOL character.
27
- * @example
28
- * ```javascript
29
- * import { format, LF, CRLF } from "@visulima/fs/eol";
30
- *
31
- * format("Hello\r\nWorld\nUnix", LF); // "Hello\nWorld\nUnix"
32
- * format("Hello\nWorld\r\nWindows", CRLF); // "Hello\r\nWorld\r\nWindows"
33
- * ```
34
- */
24
+ * Format the file to the targeted EOL.
25
+ * @param content The string content to format.
26
+ * @param eol The target EOL character.
27
+ * @example
28
+ * ```javascript
29
+ * import { format, LF, CRLF } from "@visulima/fs/eol";
30
+ *
31
+ * format("Hello\r\nWorld\nUnix", LF); // "Hello\nWorld\nUnix"
32
+ * format("Hello\nWorld\r\nWindows", CRLF); // "Hello\r\nWorld\r\nWindows"
33
+ * ```
34
+ */
35
35
  declare const format: (content: string, eol: typeof EOL) => string;
36
36
  export { CRLF, EOL, LF, detect, format };
package/dist/eol.js CHANGED
@@ -1,3 +1,3 @@
1
- import{createRequire as i}from"node:module";const u=i(import.meta.url),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{platform:p}=a,s=/\r?\n/g,c=`
1
+ import{createRequire as u}from"node:module";const i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{platform:a}=i,s=/\r?\n/g,c=`
2
2
  `,r=`\r
3
- `,_=p==="win32"?r:c,g=t=>{const e=t.match(s);if(!e||e.length===0)return null;const o=e.filter(l=>l===r).length,n=e.length-o;return o>n?r:c},h=(t,e)=>t.replaceAll(s,e);export{r as CRLF,_ as EOL,c as LF,g as detect,h as format};
3
+ `,p=a==="win32"?r:c,f=t=>{const e=t.match(s);if(!e||e.length===0)return null;const o=e.filter(l=>l===r).length,n=e.length-o;return o>n?r:c},g=(t,e)=>t.replaceAll(s,e);export{r as CRLF,p as EOL,c as LF,f as detect,g as format};
package/dist/error.d.ts CHANGED
@@ -1,36 +1,36 @@
1
- export { J as JSONError } from "./packem_shared/json-error.d-DVILOyHc.js";
1
+ export { J as JSONError } from "./packem_shared/json-error.d-COL8oxF_.js";
2
2
  /**
3
- * Error thrown when a file or directory already exists at a specified path, and an operation was expecting it not to.
4
- * @example
5
- * ```javascript
6
- * import { AlreadyExistsError } from "@visulima/fs/error"; // Assuming it's exported from an index or directly
7
- * import { ensureSymlinkSync } from "@visulima/fs"; // Or any function that might throw this
8
- * import { join } from "node:path";
9
- *
10
- * try {
11
- * // Example: ensureSymlinkSync might throw this if a file (not a symlink) already exists at linkName
12
- * // For demonstration, let's assume someFunction internally throws it:
13
- * const someFunctionThatMightThrow = (path) => {
14
- * if (path === "/tmp/existing-file.txt") { // Simulate a check
15
- * throw new AlreadyExistsError(`file already exists at '/tmp/existing-file.txt'`);
16
- * }
17
- * }
18
- * someFunctionThatMightThrow("/tmp/existing-file.txt");
19
- * } catch (error) {
20
- * if (error instanceof AlreadyExistsError) {
21
- * console.error(`Operation failed because path exists: ${error.message}`);
22
- * console.error(`Error code: ${error.code}`); // EEXIST
23
- * } else {
24
- * console.error("An unexpected error occurred:", error);
25
- * }
26
- * }
27
- * ```
28
- */
3
+ * Error thrown when a file or directory already exists at a specified path, and an operation was expecting it not to.
4
+ * @example
5
+ * ```javascript
6
+ * import { AlreadyExistsError } from "@visulima/fs/error"; // Assuming it's exported from an index or directly
7
+ * import { ensureSymlinkSync } from "@visulima/fs"; // Or any function that might throw this
8
+ * import { join } from "node:path";
9
+ *
10
+ * try {
11
+ * // Example: ensureSymlinkSync might throw this if a file (not a symlink) already exists at linkName
12
+ * // For demonstration, let's assume someFunction internally throws it:
13
+ * const someFunctionThatMightThrow = (path) => {
14
+ * if (path === "/tmp/existing-file.txt") { // Simulate a check
15
+ * throw new AlreadyExistsError(`file already exists at '/tmp/existing-file.txt'`);
16
+ * }
17
+ * }
18
+ * someFunctionThatMightThrow("/tmp/existing-file.txt");
19
+ * } catch (error) {
20
+ * if (error instanceof AlreadyExistsError) {
21
+ * console.error(`Operation failed because path exists: ${error.message}`);
22
+ * console.error(`Error code: ${error.code}`); // EEXIST
23
+ * } else {
24
+ * console.error("An unexpected error occurred:", error);
25
+ * }
26
+ * }
27
+ * ```
28
+ */
29
29
  declare class AlreadyExistsError extends Error {
30
30
  /**
31
- * Creates a new instance.
32
- * @param message
33
- */
31
+ * Creates a new instance.
32
+ * @param message
33
+ */
34
34
  constructor(message: string);
35
35
  get code(): string;
36
36
  set code(_name: string);
@@ -38,45 +38,45 @@ declare class AlreadyExistsError extends Error {
38
38
  override set name(_name: string);
39
39
  }
40
40
  /**
41
- * Error thrown when an operation that is not allowed on a directory is attempted.
42
- * This typically occurs when a file-specific operation is used on a directory path.
43
- * @example
44
- * ```javascript
45
- * import { DirectoryError } from "@visulima/fs/error";
46
- * import { readFile } from "@visulima/fs"; // Or any function that might throw this
47
- * import { join } from "node:path";
48
- *
49
- * const attemptToReadFileFromDir = async () => {
50
- * try {
51
- * // Attempting to read a directory as if it were a file
52
- * // This is a conceptual example; readFile might throw a different error first
53
- * // depending on its internal checks, but EISDIR is the underlying system error.
54
- * // Forcing the scenario:
55
- * const pretendReadFileOnDir = (path) => {
56
- * if (path === "/tmp/my-directory") { // Simulate a directory path
57
- * throw new DirectoryError(`read '/tmp/my-directory'`);
58
- * }
59
- * }
60
- * pretendReadFileOnDir("/tmp/my-directory");
61
- * // await readFile(join("/tmp", "my-directory"));
62
- * } catch (error) {
63
- * if (error instanceof DirectoryError) {
64
- * console.error(`Operation failed, path is a directory: ${error.message}`);
65
- * console.error(`Error code: ${error.code}`); // EISDIR
66
- * } else {
67
- * console.error("An unexpected error occurred:", error);
68
- * }
69
- * }
70
- * };
71
- *
72
- * attemptToReadFileFromDir();
73
- * ```
74
- */
41
+ * Error thrown when an operation that is not allowed on a directory is attempted.
42
+ * This typically occurs when a file-specific operation is used on a directory path.
43
+ * @example
44
+ * ```javascript
45
+ * import { DirectoryError } from "@visulima/fs/error";
46
+ * import { readFile } from "@visulima/fs"; // Or any function that might throw this
47
+ * import { join } from "node:path";
48
+ *
49
+ * const attemptToReadFileFromDir = async () => {
50
+ * try {
51
+ * // Attempting to read a directory as if it were a file
52
+ * // This is a conceptual example; readFile might throw a different error first
53
+ * // depending on its internal checks, but EISDIR is the underlying system error.
54
+ * // Forcing the scenario:
55
+ * const pretendReadFileOnDir = (path) => {
56
+ * if (path === "/tmp/my-directory") { // Simulate a directory path
57
+ * throw new DirectoryError(`read '/tmp/my-directory'`);
58
+ * }
59
+ * }
60
+ * pretendReadFileOnDir("/tmp/my-directory");
61
+ * // await readFile(join("/tmp", "my-directory"));
62
+ * } catch (error) {
63
+ * if (error instanceof DirectoryError) {
64
+ * console.error(`Operation failed, path is a directory: ${error.message}`);
65
+ * console.error(`Error code: ${error.code}`); // EISDIR
66
+ * } else {
67
+ * console.error("An unexpected error occurred:", error);
68
+ * }
69
+ * }
70
+ * };
71
+ *
72
+ * attemptToReadFileFromDir();
73
+ * ```
74
+ */
75
75
  declare class DirectoryError extends Error {
76
76
  /**
77
- * Creates a new instance.
78
- * @param message
79
- */
77
+ * Creates a new instance.
78
+ * @param message
79
+ */
80
80
  constructor(message: string);
81
81
  get code(): string;
82
82
  set code(_name: string);
@@ -84,49 +84,49 @@ declare class DirectoryError extends Error {
84
84
  override set name(_name: string);
85
85
  }
86
86
  /**
87
- * Error thrown when a directory is not empty.
88
- * @example
89
- * ```javascript
90
- * import { NotEmptyError } from "@visulima/fs/error";
91
- * import { rmdir } from "node:fs/promises"; // Or any fs function that might throw this system error
92
- * import { join } from "node:path";
93
- *
94
- * const attemptToRemoveNonEmptyDir = async () => {
95
- * const dirPath = join("/tmp", "my-non-empty-dir"); // Assume this directory exists and has files
96
- * try {
97
- * // Forcing the scenario for demonstration, as rmdir might throw its own specific error.
98
- * // Node.js fs operations that encounter a non-empty directory when expecting an empty one
99
- * // typically throw an error with code ENOTEMPTY.
100
- * const simulateNotEmpty = (path) => {
101
- * if (path === dirPath) { // Simulate check for non-empty
102
- * throw new NotEmptyError(`rmdir '${dirPath}'`);
103
- * }
104
- * }
105
- * simulateNotEmpty(dirPath);
106
- * // await rmdir(dirPath); // This would likely throw an error with code ENOTEMPTY
107
- * } catch (error) {
108
- * if (error instanceof NotEmptyError) {
109
- * console.error(`Operation failed, directory is not empty: ${error.message}`);
110
- * console.error(`Error code: ${error.code}`); // ENOTEMPTY
111
- * } else {
112
- * console.error("An unexpected error occurred:", error);
113
- * }
114
- * }
115
- * };
116
- *
117
- * // You would need to set up a non-empty directory at /tmp/my-non-empty-dir for a real test
118
- * // import { ensureDirSync, writeFileSync } from "@visulima/fs";
119
- * // ensureDirSync(dirPath);
120
- * // writeFileSync(join(dirPath, "somefile.txt"), "content");
121
- *
122
- * attemptToRemoveNonEmptyDir();
123
- * ```
124
- */
87
+ * Error thrown when a directory is not empty.
88
+ * @example
89
+ * ```javascript
90
+ * import { NotEmptyError } from "@visulima/fs/error";
91
+ * import { rmdir } from "node:fs/promises"; // Or any fs function that might throw this system error
92
+ * import { join } from "node:path";
93
+ *
94
+ * const attemptToRemoveNonEmptyDir = async () => {
95
+ * const dirPath = join("/tmp", "my-non-empty-dir"); // Assume this directory exists and has files
96
+ * try {
97
+ * // Forcing the scenario for demonstration, as rmdir might throw its own specific error.
98
+ * // Node.js fs operations that encounter a non-empty directory when expecting an empty one
99
+ * // typically throw an error with code ENOTEMPTY.
100
+ * const simulateNotEmpty = (path) => {
101
+ * if (path === dirPath) { // Simulate check for non-empty
102
+ * throw new NotEmptyError(`rmdir '${dirPath}'`);
103
+ * }
104
+ * }
105
+ * simulateNotEmpty(dirPath);
106
+ * // await rmdir(dirPath); // This would likely throw an error with code ENOTEMPTY
107
+ * } catch (error) {
108
+ * if (error instanceof NotEmptyError) {
109
+ * console.error(`Operation failed, directory is not empty: ${error.message}`);
110
+ * console.error(`Error code: ${error.code}`); // ENOTEMPTY
111
+ * } else {
112
+ * console.error("An unexpected error occurred:", error);
113
+ * }
114
+ * }
115
+ * };
116
+ *
117
+ * // You would need to set up a non-empty directory at /tmp/my-non-empty-dir for a real test
118
+ * // import { ensureDirSync, writeFileSync } from "@visulima/fs";
119
+ * // ensureDirSync(dirPath);
120
+ * // writeFileSync(join(dirPath, "somefile.txt"), "content");
121
+ *
122
+ * attemptToRemoveNonEmptyDir();
123
+ * ```
124
+ */
125
125
  declare class NotEmptyError extends Error {
126
126
  /**
127
- * Creates a new instance.
128
- * @param message
129
- */
127
+ * Creates a new instance.
128
+ * @param message
129
+ */
130
130
  constructor(message: string);
131
131
  get code(): string;
132
132
  set code(_name: string);
@@ -134,42 +134,42 @@ declare class NotEmptyError extends Error {
134
134
  override set name(_name: string);
135
135
  }
136
136
  /**
137
- * Error thrown when a file or directory is not found at a specified path.
138
- * @example
139
- * ```javascript
140
- * import { NotFoundError } from "@visulima/fs/error";
141
- * import { readFile } from "@visulima/fs"; // Or any function that might throw this
142
- * import { join } from "node:path";
143
- *
144
- * const tryReadingNonExistentFile = async () => {
145
- * const filePath = join("/tmp", "this-file-does-not-exist.txt");
146
- * try {
147
- * // Forcing the scenario for demonstration, as readFile itself would throw this.
148
- * const simulateNotFound = (path) => {
149
- * if (path === filePath) {
150
- * throw new NotFoundError(`no such file or directory, open '${filePath}'`);
151
- * }
152
- * }
153
- * simulateNotFound(filePath);
154
- * // await readFile(filePath);
155
- * } catch (error) {
156
- * if (error instanceof NotFoundError) {
157
- * console.error(`Operation failed, path not found: ${error.message}`);
158
- * console.error(`Error code: ${error.code}`); // ENOENT
159
- * } else {
160
- * console.error("An unexpected error occurred:", error);
161
- * }
162
- * }
163
- * };
164
- *
165
- * tryReadingNonExistentFile();
166
- * ```
167
- */
137
+ * Error thrown when a file or directory is not found at a specified path.
138
+ * @example
139
+ * ```javascript
140
+ * import { NotFoundError } from "@visulima/fs/error";
141
+ * import { readFile } from "@visulima/fs"; // Or any function that might throw this
142
+ * import { join } from "node:path";
143
+ *
144
+ * const tryReadingNonExistentFile = async () => {
145
+ * const filePath = join("/tmp", "this-file-does-not-exist.txt");
146
+ * try {
147
+ * // Forcing the scenario for demonstration, as readFile itself would throw this.
148
+ * const simulateNotFound = (path) => {
149
+ * if (path === filePath) {
150
+ * throw new NotFoundError(`no such file or directory, open '${filePath}'`);
151
+ * }
152
+ * }
153
+ * simulateNotFound(filePath);
154
+ * // await readFile(filePath);
155
+ * } catch (error) {
156
+ * if (error instanceof NotFoundError) {
157
+ * console.error(`Operation failed, path not found: ${error.message}`);
158
+ * console.error(`Error code: ${error.code}`); // ENOENT
159
+ * } else {
160
+ * console.error("An unexpected error occurred:", error);
161
+ * }
162
+ * }
163
+ * };
164
+ *
165
+ * tryReadingNonExistentFile();
166
+ * ```
167
+ */
168
168
  declare class NotFoundError extends Error {
169
169
  /**
170
- * Creates a new instance.
171
- * @param message
172
- */
170
+ * Creates a new instance.
171
+ * @param message
172
+ */
173
173
  constructor(message: string);
174
174
  get code(): string;
175
175
  set code(_name: string);
@@ -177,43 +177,43 @@ declare class NotFoundError extends Error {
177
177
  override set name(_name: string);
178
178
  }
179
179
  /**
180
- * Error thrown when an operation is not permitted due to insufficient privileges
181
- * or other access control restrictions.
182
- * @example
183
- * ```javascript
184
- * import { PermissionError } from "@visulima/fs/error";
185
- * import { writeFile } from "@visulima/fs"; // Or any function that might throw this
186
- * import { join } from "node:path";
187
- *
188
- * const tryWritingToProtectedFile = async () => {
189
- * const filePath = join("/root", "protected-file.txt"); // A path that typically requires root privileges
190
- * try {
191
- * // Forcing the scenario for demonstration, as writeFile itself would throw this.
192
- * const simulatePermissionError = (path) => {
193
- * if (path === filePath) {
194
- * throw new PermissionError(`open '${filePath}'`);
195
- * }
196
- * }
197
- * simulatePermissionError(filePath);
198
- * // await writeFile(filePath, "test content");
199
- * } catch (error) {
200
- * if (error instanceof PermissionError) {
201
- * console.error(`Operation not permitted: ${error.message}`);
202
- * console.error(`Error code: ${error.code}`); // EPERM
203
- * } else {
204
- * console.error("An unexpected error occurred:", error);
205
- * }
206
- * }
207
- * };
208
- *
209
- * tryWritingToProtectedFile();
210
- * ```
211
- */
180
+ * Error thrown when an operation is not permitted due to insufficient privileges
181
+ * or other access control restrictions.
182
+ * @example
183
+ * ```javascript
184
+ * import { PermissionError } from "@visulima/fs/error";
185
+ * import { writeFile } from "@visulima/fs"; // Or any function that might throw this
186
+ * import { join } from "node:path";
187
+ *
188
+ * const tryWritingToProtectedFile = async () => {
189
+ * const filePath = join("/root", "protected-file.txt"); // A path that typically requires root privileges
190
+ * try {
191
+ * // Forcing the scenario for demonstration, as writeFile itself would throw this.
192
+ * const simulatePermissionError = (path) => {
193
+ * if (path === filePath) {
194
+ * throw new PermissionError(`open '${filePath}'`);
195
+ * }
196
+ * }
197
+ * simulatePermissionError(filePath);
198
+ * // await writeFile(filePath, "test content");
199
+ * } catch (error) {
200
+ * if (error instanceof PermissionError) {
201
+ * console.error(`Operation not permitted: ${error.message}`);
202
+ * console.error(`Error code: ${error.code}`); // EPERM
203
+ * } else {
204
+ * console.error("An unexpected error occurred:", error);
205
+ * }
206
+ * }
207
+ * };
208
+ *
209
+ * tryWritingToProtectedFile();
210
+ * ```
211
+ */
212
212
  declare class PermissionError extends Error {
213
213
  /**
214
- * Creates a new instance.
215
- * @param message
216
- */
214
+ * Creates a new instance.
215
+ * @param message
216
+ */
217
217
  constructor(message: string);
218
218
  get code(): string;
219
219
  set code(_name: string);
@@ -221,51 +221,51 @@ declare class PermissionError extends Error {
221
221
  override set name(_name: string);
222
222
  }
223
223
  /**
224
- * Error thrown in walk or walkSync during iteration.
225
- * @example
226
- * ```javascript
227
- * import { WalkError } from "@visulima/fs/error";
228
- * import { walk } from "@visulima/fs";
229
- * import { join } from "node:path";
230
- *
231
- * const processDirectory = async () => {
232
- * const dirToWalk = join("/tmp", "non-existent-or-permission-denied-dir");
233
- * try {
234
- * // Forcing the scenario: walk might throw a WalkError if it encounters an issue
235
- * // like a directory it cannot read during the walk process.
236
- * const simulateWalkError = async (rootDir) => {
237
- * // Let's say readdir inside walk fails for a subdirectory.
238
- * const underlyingError = new Error("Permission denied reading subdirectory");
239
- * throw new WalkError(underlyingError, rootDir);
240
- * }
241
- * // This is conceptual. In a real scenario, 'walk' itself would throw.
242
- * // for await (const entry of walk(dirToWalk)) {
243
- * // console.log(entry.path);
244
- * // }
245
- * await simulateWalkError(dirToWalk);
246
- * } catch (error) {
247
- * if (error instanceof WalkError) {
248
- * console.error(`Error during directory walk of "${error.root}": ${error.message}`);
249
- * if (error.cause) {
250
- * console.error(`Underlying cause: ${error.cause}`);
251
- * }
252
- * } else {
253
- * console.error("An unexpected error occurred:", error);
254
- * }
255
- * }
256
- * };
257
- *
258
- * processDirectory();
259
- * ```
260
- */
224
+ * Error thrown in walk or walkSync during iteration.
225
+ * @example
226
+ * ```javascript
227
+ * import { WalkError } from "@visulima/fs/error";
228
+ * import { walk } from "@visulima/fs";
229
+ * import { join } from "node:path";
230
+ *
231
+ * const processDirectory = async () => {
232
+ * const dirToWalk = join("/tmp", "non-existent-or-permission-denied-dir");
233
+ * try {
234
+ * // Forcing the scenario: walk might throw a WalkError if it encounters an issue
235
+ * // like a directory it cannot read during the walk process.
236
+ * const simulateWalkError = async (rootDir) => {
237
+ * // Let's say readdir inside walk fails for a subdirectory.
238
+ * const underlyingError = new Error("Permission denied reading subdirectory");
239
+ * throw new WalkError(underlyingError, rootDir);
240
+ * }
241
+ * // This is conceptual. In a real scenario, 'walk' itself would throw.
242
+ * // for await (const entry of walk(dirToWalk)) {
243
+ * // console.log(entry.path);
244
+ * // }
245
+ * await simulateWalkError(dirToWalk);
246
+ * } catch (error) {
247
+ * if (error instanceof WalkError) {
248
+ * console.error(`Error during directory walk of "${error.root}": ${error.message}`);
249
+ * if (error.cause) {
250
+ * console.error(`Underlying cause: ${error.cause}`);
251
+ * }
252
+ * } else {
253
+ * console.error("An unexpected error occurred:", error);
254
+ * }
255
+ * }
256
+ * };
257
+ *
258
+ * processDirectory();
259
+ * ```
260
+ */
261
261
  declare class WalkError extends Error {
262
262
  /** File path of the root that's being walked. */
263
263
  root: string;
264
264
  /**
265
- * Constructs a new instance.
266
- * @param cause The underlying error or reason for the walk failure.
267
- * @param root The root directory path where the walk operation started or encountered the error.
268
- */
265
+ * Constructs a new instance.
266
+ * @param cause The underlying error or reason for the walk failure.
267
+ * @param root The root directory path where the walk operation started or encountered the error.
268
+ */
269
269
  constructor(cause: unknown, root: string);
270
270
  override get name(): string;
271
271
  override set name(_name: string);
@@ -1,35 +1,35 @@
1
1
  /**
2
- * Options accepted by {@link globParent}.
3
- */
2
+ * Options accepted by {@link globParent}.
3
+ */
4
4
  interface GlobParentOptions {
5
5
  /**
6
- * On Windows, flip backslashes to forward slashes before analysing the pattern.
7
- *
8
- * Disable when the input contains backslash escape sequences you want to preserve.
9
- * @default true
10
- */
6
+ * On Windows, flip backslashes to forward slashes before analysing the pattern.
7
+ *
8
+ * Disable when the input contains backslash escape sequences you want to preserve.
9
+ * @default true
10
+ */
11
11
  flipBackslashes?: boolean;
12
12
  }
13
13
  /**
14
- * Extracts the non-glob parent directory from a glob pattern.
15
- *
16
- * Useful when you need to know which directory to watch or walk for a given pattern — for example
17
- * `src/**\/*.ts` → `src`, `foo/{a,b}/*.js` → `foo`. Patterns without glob characters are returned
18
- * unchanged.
19
- *
20
- * Powered by [`glob-parent`](https://github.com/gulpjs/glob-parent) which is bundled into the built output so
21
- * it does not appear as a runtime dependency of `@visulima/fs`.
22
- * @param pattern The glob pattern to inspect.
23
- * @param options Optional configuration. See {@link GlobParentOptions}.
24
- * @returns The static parent path of the glob.
25
- * @example
26
- * ```javascript
27
- * import { globParent } from "@visulima/fs";
28
- *
29
- * globParent("src/**\/*.ts"); // "src"
30
- * globParent("foo/{a,b}/*.js"); // "foo"
31
- * globParent("foo/bar.js"); // "foo/bar.js"
32
- * ```
33
- */
14
+ * Extracts the non-glob parent directory from a glob pattern.
15
+ *
16
+ * Useful when you need to know which directory to watch or walk for a given pattern — for example
17
+ * `src/**\/*.ts` → `src`, `foo/{a,b}/*.js` → `foo`. Patterns without glob characters are returned
18
+ * unchanged.
19
+ *
20
+ * Powered by [`glob-parent`](https://github.com/gulpjs/glob-parent) which is bundled into the built output so
21
+ * it does not appear as a runtime dependency of `@visulima/fs`.
22
+ * @param pattern The glob pattern to inspect.
23
+ * @param options Optional configuration. See {@link GlobParentOptions}.
24
+ * @returns The static parent path of the glob.
25
+ * @example
26
+ * ```javascript
27
+ * import { globParent } from "@visulima/fs";
28
+ *
29
+ * globParent("src/**\/*.ts"); // "src"
30
+ * globParent("foo/{a,b}/*.js"); // "foo"
31
+ * globParent("foo/bar.js"); // "foo/bar.js"
32
+ * ```
33
+ */
34
34
  declare const globParent: (pattern: string, options?: GlobParentOptions) => string;
35
35
  export { type GlobParentOptions, globParent as default };
@@ -1 +1 @@
1
- import{createRequire as g}from"node:module";import{g as _}from"./packem_shared/_commonjsHelpers-CWAkuNXM.js";import{r as v}from"./packem_shared/index-BHy3Kcr7.js";const h=g(import.meta.url),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=s=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[r,o]=i.versions.node.split(".").map(Number);if(r>22||r===22&&o>=3||r===20&&o>=16)return i.getBuiltinModule(s)}return h(s)},q=f("path"),j=f("os");var l,u;function x(){if(u)return l;u=1;var s=v(),r=q.posix.dirname,o=j.platform()==="win32",n="/",p=/\\/g,d=/\\([!*?|[\](){}])/g;l=function(e,a){var t=Object.assign({flipBackslashes:!0},a);t.flipBackslashes&&o&&e.indexOf(n)<0&&(e=e.replace(p,n)),b(e)&&(e+=n),e+="a";do e=r(e);while(m(e));return e.replace(d,"$1")};function b(e){var a=e.slice(-1),t;switch(a){case"}":t="{";break;case"]":t="[";break;default:return!1}var c=e.indexOf(t);return c<0?!1:e.slice(c+1,-1).includes(n)}function m(e){return/\([^()]+$/.test(e)||e[0]==="{"||e[0]==="["||/[^\\][{[]/.test(e)?!0:s(e)}return l}var P=x();const $=_(P),B=(s,r)=>$(s,r);export{B as default};
1
+ import{createRequire as _}from"node:module";import{g as v}from"./packem_shared/_commonjsHelpers-CWAkuNXM.js";import{r as q}from"./packem_shared/index-BHy3Kcr7.js";let g;const h=r=>(g??=_(import.meta.url))(r),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=r=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[s,o]=i.versions.node.split(".").map(Number);if(s>22||s===22&&o>=3||s===20&&o>=16)return i.getBuiltinModule(r)}return h(r)},j=f("path"),x=f("os");var c,u;function P(){if(u)return c;u=1;var r=q(),s=j.posix.dirname,o=x.platform()==="win32",n="/",p=/\\/g,d=/\\([!*?|[\](){}])/g;c=function(e,a){var t=Object.assign({flipBackslashes:!0},a);t.flipBackslashes&&o&&e.indexOf(n)<0&&(e=e.replace(p,n)),b(e)&&(e+=n),e+="a";do e=s(e);while(m(e));return e.replace(d,"$1")};function b(e){var a=e.slice(-1),t;switch(a){case"}":t="{";break;case"]":t="[";break;default:return!1}var l=e.indexOf(t);return l<0?!1:e.slice(l+1,-1).includes(n)}function m(e){return/\([^()]+$/.test(e)||e[0]==="{"||e[0]==="["||/[^\\][{[]/.test(e)?!0:r(e)}return c}var $=P();const k=v($),R=(r,s)=>k(r,s);export{R as default};
package/dist/glob.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { g as glob, a as globSync } from "./packem_shared/glob-sync.d-hXe38TnZ.js";
2
- export type { G as GlobOptions } from "./packem_shared/types.d-BMdL_ygj.js";
1
+ export { g as glob, a as globSync } from "./packem_shared/glob-sync.d-DaAZHTsv.js";
2
+ export type { G as GlobOptions } from "./packem_shared/types.d-D3Jo_iA-.js";
3
3
  import 'node:fs';
4
4
  import 'fdir';
package/dist/glob.js CHANGED
@@ -1 +1 @@
1
- import{default as e}from"./packem_shared/glob-DMbPwGSj.js";import{default as l}from"./packem_shared/globSync-DiP2rtGn.js";export{e as glob,l as globSync};
1
+ import{default as e}from"./packem_shared/glob-BUjyjdE8.js";import{default as l}from"./packem_shared/globSync-Bk9TUV7x.js";export{e as glob,l as globSync};