@visulima/fs 5.0.0-alpha.12 → 5.0.0-alpha.13

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/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## @visulima/fs [5.0.0-alpha.13](https://github.com/visulima/visulima/compare/@visulima/fs@5.0.0-alpha.12...@visulima/fs@5.0.0-alpha.13) (2026-05-04)
2
+
3
+ ### Miscellaneous Chores
4
+
5
+ * **fs:** upgrade packem to 2.0.0-alpha.76 ([3dfa709](https://github.com/visulima/visulima/commit/3dfa709d723dd74576ce7003c63c11858c1e72e3))
6
+ * re-sort workspace package.json files via vis sort-package-json ([f625696](https://github.com/visulima/visulima/commit/f625696cfac974325774b3243e1a83c3d23acbd7))
7
+ * simplify pnpm-workspace packages list ([7cab221](https://github.com/visulima/visulima/commit/7cab221163632d9b7aa044a6f88c49083103a869))
8
+
9
+
10
+ ### Dependencies
11
+
12
+ * **@visulima/error:** upgraded to 6.0.0-alpha.15
13
+
1
14
  ## @visulima/fs [5.0.0-alpha.12](https://github.com/visulima/visulima/compare/@visulima/fs@5.0.0-alpha.11...@visulima/fs@5.0.0-alpha.12) (2026-04-22)
2
15
 
3
16
  ### Bug Fixes
package/LICENSE.md CHANGED
@@ -281,14 +281,11 @@ Repository: git+https://github.com/SuperchupuDev/tinyglobby.git
281
281
  <!-- TYPE_DEPENDENCIES -->
282
282
 
283
283
  # Licenses of bundled types
284
-
285
284
  The published @visulima/fs artifact additionally contains code with the following licenses:
286
- MIT
285
+ ISC, MIT
287
286
 
288
287
  # Bundled types:
289
-
290
288
  ## is-fs-case-sensitive
291
-
292
289
  License: MIT
293
290
  By: Hiroki Osame
294
291
  Repository: privatenumber/is-fs-case-sensitive
@@ -315,4 +312,25 @@ Repository: privatenumber/is-fs-case-sensitive
315
312
  > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
316
313
  > SOFTWARE.
317
314
 
315
+ ---------------------------------------
316
+
317
+ ## yaml
318
+ License: ISC
319
+ By: Eemeli Aro
320
+ Repository: github:eemeli/yaml
321
+
322
+ > Copyright Eemeli Aro <eemeli@gmail.com>
323
+ >
324
+ > Permission to use, copy, modify, and/or distribute this software for any purpose
325
+ > with or without fee is hereby granted, provided that the above copyright notice
326
+ > and this permission notice appear in all copies.
327
+ >
328
+ > THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
329
+ > REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
330
+ > FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
331
+ > INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
332
+ > OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
333
+ > TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
334
+ > THIS SOFTWARE.
335
+
318
336
  <!-- /TYPE_DEPENDENCIES -->
package/dist/eol.d.ts CHANGED
@@ -1,6 +1,36 @@
1
+ /** End-of-line character for POSIX platforms such as macOS and Linux. */
1
2
  declare const LF: "\n";
3
+ /** End-of-line character for Windows platforms. */
2
4
  declare const CRLF: "\r\n";
5
+ /**
6
+ * End-of-line character evaluated for the current platform.
7
+ */
3
8
  declare const EOL: "\n" | "\r\n";
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
+ */
4
22
  declare const detect: (content: string) => typeof EOL | null;
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
+ */
5
35
  declare const format: (content: string, eol: typeof EOL) => string;
6
36
  export { CRLF, EOL, LF, detect, format };
package/dist/error.d.ts CHANGED
@@ -1,43 +1,273 @@
1
- export { J as JSONError } from "./packem_shared/json-error.d-DgKaeuIf.js";
1
+ export { J as JSONError } from "./packem_shared/json-error.d-DVILOyHc.js";
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
+ */
2
29
  declare class AlreadyExistsError extends Error {
30
+ /**
31
+ * Creates a new instance.
32
+ * @param message
33
+ */
3
34
  constructor(message: string);
4
35
  get code(): string;
5
36
  set code(_name: string);
6
- get name(): string;
7
- set name(_name: string);
37
+ override get name(): string;
38
+ override set name(_name: string);
8
39
  }
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
+ */
9
75
  declare class DirectoryError extends Error {
76
+ /**
77
+ * Creates a new instance.
78
+ * @param message
79
+ */
10
80
  constructor(message: string);
11
81
  get code(): string;
12
82
  set code(_name: string);
13
- get name(): string;
14
- set name(_name: string);
83
+ override get name(): string;
84
+ override set name(_name: string);
15
85
  }
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
+ */
16
125
  declare class NotEmptyError extends Error {
126
+ /**
127
+ * Creates a new instance.
128
+ * @param message
129
+ */
17
130
  constructor(message: string);
18
131
  get code(): string;
19
132
  set code(_name: string);
20
- get name(): string;
21
- set name(_name: string);
133
+ override get name(): string;
134
+ override set name(_name: string);
22
135
  }
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
+ */
23
168
  declare class NotFoundError extends Error {
169
+ /**
170
+ * Creates a new instance.
171
+ * @param message
172
+ */
24
173
  constructor(message: string);
25
174
  get code(): string;
26
175
  set code(_name: string);
27
- get name(): string;
28
- set name(_name: string);
176
+ override get name(): string;
177
+ override set name(_name: string);
29
178
  }
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
+ */
30
212
  declare class PermissionError extends Error {
213
+ /**
214
+ * Creates a new instance.
215
+ * @param message
216
+ */
31
217
  constructor(message: string);
32
218
  get code(): string;
33
219
  set code(_name: string);
34
- get name(): string;
35
- set name(_name: string);
220
+ override get name(): string;
221
+ override set name(_name: string);
36
222
  }
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
+ */
37
261
  declare class WalkError extends Error {
262
+ /** File path of the root that's being walked. */
38
263
  root: string;
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
+ */
39
269
  constructor(cause: unknown, root: string);
40
- get name(): string;
41
- set name(_name: string);
270
+ override get name(): string;
271
+ override set name(_name: string);
42
272
  }
43
273
  export { AlreadyExistsError, DirectoryError, NotEmptyError, NotFoundError, PermissionError, WalkError };
@@ -1,5 +1,35 @@
1
+ /**
2
+ * Options accepted by {@link globParent}.
3
+ */
1
4
  interface GlobParentOptions {
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
+ */
2
11
  flipBackslashes?: boolean;
3
12
  }
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
+ */
4
34
  declare const globParent: (pattern: string, options?: GlobParentOptions) => string;
5
35
  export { type GlobParentOptions, globParent as default };
package/dist/glob.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- export { g as glob, a as globSync } from "./packem_shared/glob-sync.d-BlGjS68e.js";
2
- export { type G as GlobOptions } from "./packem_shared/types.d-CYpAhWov.js";
1
+ export { g as glob, a as globSync } from "./packem_shared/glob-sync.d-Dsxhj3BW.js";
2
+ export { type G as GlobOptions } from "./packem_shared/types.d-CixEXeyM.js";
3
3
  import 'node:fs';
4
4
  import 'tinyglobby';
5
- import './options';