@visulima/fs 5.0.9 → 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.
- package/CHANGELOG.md +4 -0
- package/dist/eol.d.ts +25 -25
- package/dist/eol.js +2 -2
- package/dist/error.d.ts +218 -218
- package/dist/glob-parent.d.ts +27 -27
- package/dist/glob-parent.js +1 -1
- package/dist/glob.d.ts +2 -2
- package/dist/glob.js +1 -1
- package/dist/index.d.ts +765 -765
- package/dist/index.js +1 -1
- package/dist/ini.d.ts +59 -59
- package/dist/ini.js +1 -1
- package/dist/is-glob.d.ts +26 -26
- package/dist/json5.d.ts +25 -25
- package/dist/json5.js +1 -1
- package/dist/jsonc.d.ts +54 -54
- package/dist/jsonc.js +1 -1
- package/dist/match.d.ts +40 -40
- package/dist/packem_shared/{collect-CIKDOMiD.js → collect-B0S0bJoE.js} +1 -1
- package/dist/packem_shared/{collectSync-D0FRLLqg.js → collectSync-0M1eoilI.js} +1 -1
- package/dist/packem_shared/copy-DiR5_5iA.js +1 -0
- package/dist/packem_shared/copySync-DffsYlhb.js +1 -0
- package/dist/packem_shared/emptyDir-BlBeczk0.js +1 -0
- package/dist/packem_shared/emptyDirSync-DfUZ9Ejz.js +1 -0
- package/dist/packem_shared/ensureDir-BEiomfxz.js +1 -0
- package/dist/packem_shared/ensureDirSync-B0w9WMwE.js +1 -0
- package/dist/packem_shared/ensureFile-waD4hDO8.js +1 -0
- package/dist/packem_shared/ensureFileSync-CG07zjV7.js +1 -0
- package/dist/packem_shared/ensureLink-Dz-PDWa5.js +1 -0
- package/dist/packem_shared/ensureLinkSync-BZH7TaSQ.js +1 -0
- package/dist/packem_shared/ensureSymlink-Byi6ajoE.js +1 -0
- package/dist/packem_shared/ensureSymlinkSync-D7OCsAd8.js +1 -0
- package/dist/packem_shared/findUp-Ylerv_a2.js +1 -0
- package/dist/packem_shared/findUpSync-BWBPRzEq.js +1 -0
- package/dist/packem_shared/glob-BUjyjdE8.js +1 -0
- package/dist/packem_shared/glob-sync.d-DaAZHTsv.d.ts +54 -0
- package/dist/packem_shared/globSync-Bk9TUV7x.js +1 -0
- package/dist/packem_shared/index-CPZbuHkp.js +1 -0
- package/dist/packem_shared/isAccessible-B7guOm3k.js +1 -0
- package/dist/packem_shared/isAccessibleSync-XH4YleJW.js +1 -0
- package/dist/packem_shared/json-error.d-COL8oxF_.d.ts +52 -0
- package/dist/packem_shared/move-KhPRvsRd.js +1 -0
- package/dist/packem_shared/{parseJson-EASgP4J9.js → parseJson-_OfIPruP.js} +1 -1
- package/dist/packem_shared/readFile-VgxUDrNH.js +1 -0
- package/dist/packem_shared/readFileSync-CloFeQw8.js +1 -0
- package/dist/packem_shared/{readIni-BsXudu2r.js → readIni-CEXHWn92.js} +1 -1
- package/dist/packem_shared/readIniSync-DsxVHypc.js +1 -0
- package/dist/packem_shared/{readJson-CcAsHxE5.js → readJson-Q3T3RlSy.js} +1 -1
- package/dist/packem_shared/{readJson5-CM1TIiHd.js → readJson5-S68aVros.js} +1 -1
- package/dist/packem_shared/{readJson5Sync-Bc26c3Fy.js → readJson5Sync-Bi9Rv46R.js} +1 -1
- package/dist/packem_shared/{readJsonSync-DuMMeB3s.js → readJsonSync-BnWiH5-R.js} +1 -1
- package/dist/packem_shared/{readJsonc-BZjMw_0f.js → readJsonc-DSoFyuDk.js} +1 -1
- package/dist/packem_shared/{readJsoncSync-C-xzeZz4.js → readJsoncSync-CLtlvFKV.js} +1 -1
- package/dist/packem_shared/readToml-CN_xnICv.js +1 -0
- package/dist/packem_shared/readTomlSync-B9TVGzen.js +1 -0
- package/dist/packem_shared/{readYaml-DvPxndW_.js → readYaml-DcpUq11D.js} +1 -1
- package/dist/packem_shared/{readYamlSync-DZ-0hSbZ.js → readYamlSync-D5RVZwco.js} +1 -1
- package/dist/packem_shared/remove-D_CUIlBL.js +1 -0
- package/dist/packem_shared/removeSync-F4nKiwrU.js +1 -0
- package/dist/packem_shared/renderError-DjesnVYT-pWsLqw-_.js +6 -0
- package/dist/packem_shared/sanitize-aEqeyx4d.js +1 -0
- package/dist/packem_shared/to-uint-8-array-7sXMoZwU.js +1 -0
- package/dist/packem_shared/{types.d-BMdL_ygj.d.ts → types.d-D3Jo_iA-.d.ts} +361 -383
- package/dist/packem_shared/walk-BReeHTKb.js +1 -0
- package/dist/packem_shared/walkSync-yHJUIJb9.js +1 -0
- package/dist/packem_shared/writeFile-srDcYaRC.js +1 -0
- package/dist/packem_shared/writeFileSync-Ddl_u4my.js +1 -0
- package/dist/packem_shared/writeIni-CKinbquM.js +4 -0
- package/dist/packem_shared/writeIniSync-BISRFyg0.js +4 -0
- package/dist/packem_shared/writeJson-DlCrFMXb.js +4 -0
- package/dist/packem_shared/writeJson5-rSp3QAKP.js +4 -0
- package/dist/packem_shared/writeJson5Sync-tSBBKnaP.js +4 -0
- package/dist/packem_shared/writeJsonSync-CKqVRz_9.js +4 -0
- package/dist/packem_shared/writeJsonc-bxz1jdeU.js +4 -0
- package/dist/packem_shared/writeJsoncSync-C-W0H9qP.js +4 -0
- package/dist/packem_shared/{writeToml-IuMO-yDu.js → writeToml-CrpfWNyK.js} +1 -1
- package/dist/packem_shared/{writeTomlSync-DhL7hHzB.js → writeTomlSync-DveRchLG.js} +1 -1
- package/dist/packem_shared/{writeYaml-ClQgvQID.js → writeYaml-DvSQ_Jbn.js} +1 -1
- package/dist/packem_shared/{writeYamlSync-DrXtHQQq.js → writeYamlSync-CEf0PUGQ.js} +1 -1
- package/dist/size.d.ts +236 -236
- package/dist/size.js +1 -1
- package/dist/toml.d.ts +52 -52
- package/dist/toml.js +1 -1
- package/dist/utils.d.ts +88 -88
- package/dist/utils.js +1 -1
- package/dist/yaml.d.ts +2 -2
- package/dist/yaml.js +1 -1
- package/package.json +1 -1
- package/dist/packem_shared/copy-Beb64BYG.js +0 -1
- package/dist/packem_shared/copySync-CagcIEBi.js +0 -1
- package/dist/packem_shared/emptyDir-C7lyd1lW.js +0 -1
- package/dist/packem_shared/emptyDirSync-B8EYpmO9.js +0 -1
- package/dist/packem_shared/ensureDir-DGarVZw8.js +0 -1
- package/dist/packem_shared/ensureDirSync-CsgPrsDH.js +0 -1
- package/dist/packem_shared/ensureFile-CMugWljp.js +0 -1
- package/dist/packem_shared/ensureFileSync-CJYTEx2r.js +0 -1
- package/dist/packem_shared/ensureLink-ChShf3lf.js +0 -1
- package/dist/packem_shared/ensureLinkSync-DPpq0I2Z.js +0 -1
- package/dist/packem_shared/ensureSymlink-y4FZjfxA.js +0 -1
- package/dist/packem_shared/ensureSymlinkSync-TcHssCH7.js +0 -1
- package/dist/packem_shared/findUp-Cii5ATt5.js +0 -1
- package/dist/packem_shared/findUpSync-C9Lkh7-v.js +0 -1
- package/dist/packem_shared/glob-DMbPwGSj.js +0 -1
- package/dist/packem_shared/glob-sync.d-hXe38TnZ.d.ts +0 -54
- package/dist/packem_shared/globSync-DiP2rtGn.js +0 -1
- package/dist/packem_shared/index-Ct4GqZSP.js +0 -1
- package/dist/packem_shared/isAccessible-PmWJhV6I.js +0 -1
- package/dist/packem_shared/isAccessibleSync-BrbOtwdr.js +0 -1
- package/dist/packem_shared/json-error.d-DVILOyHc.d.ts +0 -52
- package/dist/packem_shared/move-DopmzT-2.js +0 -1
- package/dist/packem_shared/readFile-BswaBgM0.js +0 -1
- package/dist/packem_shared/readFileSync-_fDF6Oj1.js +0 -1
- package/dist/packem_shared/readIniSync-DKwRbbs9.js +0 -1
- package/dist/packem_shared/readToml-D4jpe9q_.js +0 -1
- package/dist/packem_shared/readTomlSync-B5PIYT9z.js +0 -1
- package/dist/packem_shared/remove-CSbrd0dl.js +0 -1
- package/dist/packem_shared/removeSync-BoLAzRQE.js +0 -1
- package/dist/packem_shared/renderError-B3ePOoBG-Bi9WKMjv.js +0 -6
- package/dist/packem_shared/sanitize-DGZ3w-_w.js +0 -1
- package/dist/packem_shared/to-uint-8-array-BImOQNXm.js +0 -1
- package/dist/packem_shared/walk-OX4-6oCP.js +0 -1
- package/dist/packem_shared/walkSync-BPs6czIM.js +0 -1
- package/dist/packem_shared/writeFile-BrMtsJY7.js +0 -1
- package/dist/packem_shared/writeFileSync-W7Mf4BNy.js +0 -1
- package/dist/packem_shared/writeIni-BWX3cP1K.js +0 -4
- package/dist/packem_shared/writeIniSync-fOdgPFfL.js +0 -4
- package/dist/packem_shared/writeJson-bEVi25gX.js +0 -4
- package/dist/packem_shared/writeJson5-Ch8TpNPI.js +0 -4
- package/dist/packem_shared/writeJson5Sync-BrctV_Mk.js +0 -4
- package/dist/packem_shared/writeJsonSync-DkGnd416.js +0 -4
- package/dist/packem_shared/writeJsonc-CefrwsOc.js +0 -4
- package/dist/packem_shared/writeJsoncSync-BskDjn8o.js +0 -4
package/dist/toml.d.ts
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import { C as CompressionType, i as ReadTomlOptions, j as WriteTomlOptions } from "./packem_shared/types.d-
|
|
1
|
+
import { C as CompressionType, i as ReadTomlOptions, j as WriteTomlOptions } from "./packem_shared/types.d-D3Jo_iA-.js";
|
|
2
2
|
import 'node:fs';
|
|
3
3
|
import 'fdir';
|
|
4
4
|
/**
|
|
5
|
-
* Asynchronously reads a TOML file and parses it into an object.
|
|
6
|
-
* @template R The expected type of the parsed TOML object. Defaults to `Record<string, unknown>`.
|
|
7
|
-
* @param path The path to the TOML file to read. Can be a file URL or a string path.
|
|
8
|
-
* @param options Optional configuration for reading the file. See {@link ReadTomlOptions}.
|
|
9
|
-
* @returns A promise that resolves with the parsed TOML object of type `R`.
|
|
10
|
-
* @example
|
|
11
|
-
* ```javascript
|
|
12
|
-
* import { readToml } from "@visulima/fs/toml";
|
|
13
|
-
* import { join } from "node:path";
|
|
14
|
-
*
|
|
15
|
-
* const config = await readToml(join("path", "to", "config.toml"));
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
5
|
+
* Asynchronously reads a TOML file and parses it into an object.
|
|
6
|
+
* @template R The expected type of the parsed TOML object. Defaults to `Record<string, unknown>`.
|
|
7
|
+
* @param path The path to the TOML file to read. Can be a file URL or a string path.
|
|
8
|
+
* @param options Optional configuration for reading the file. See {@link ReadTomlOptions}.
|
|
9
|
+
* @returns A promise that resolves with the parsed TOML object of type `R`.
|
|
10
|
+
* @example
|
|
11
|
+
* ```javascript
|
|
12
|
+
* import { readToml } from "@visulima/fs/toml";
|
|
13
|
+
* import { join } from "node:path";
|
|
14
|
+
*
|
|
15
|
+
* const config = await readToml(join("path", "to", "config.toml"));
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
18
|
declare const readToml: <R = Record<string, unknown>>(path: URL | string, options?: ReadTomlOptions<CompressionType>) => Promise<R>;
|
|
19
19
|
/**
|
|
20
|
-
* Synchronously reads a TOML file and parses it into an object.
|
|
21
|
-
* @template R The expected type of the parsed TOML object. Defaults to `Record<string, unknown>`.
|
|
22
|
-
* @param path The path to the TOML file to read. Can be a file URL or a string path.
|
|
23
|
-
* @param options Optional configuration for reading the file. See {@link ReadTomlOptions}.
|
|
24
|
-
* @returns The parsed TOML object of type `R`.
|
|
25
|
-
* @example
|
|
26
|
-
* ```javascript
|
|
27
|
-
* import { readTomlSync } from "@visulima/fs/toml";
|
|
28
|
-
* import { join } from "node:path";
|
|
29
|
-
*
|
|
30
|
-
* const config = readTomlSync(join("path", "to", "config.toml"));
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
20
|
+
* Synchronously reads a TOML file and parses it into an object.
|
|
21
|
+
* @template R The expected type of the parsed TOML object. Defaults to `Record<string, unknown>`.
|
|
22
|
+
* @param path The path to the TOML file to read. Can be a file URL or a string path.
|
|
23
|
+
* @param options Optional configuration for reading the file. See {@link ReadTomlOptions}.
|
|
24
|
+
* @returns The parsed TOML object of type `R`.
|
|
25
|
+
* @example
|
|
26
|
+
* ```javascript
|
|
27
|
+
* import { readTomlSync } from "@visulima/fs/toml";
|
|
28
|
+
* import { join } from "node:path";
|
|
29
|
+
*
|
|
30
|
+
* const config = readTomlSync(join("path", "to", "config.toml"));
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
33
|
declare const readTomlSync: (path: URL | string, options?: ReadTomlOptions<CompressionType>) => Record<string, unknown>;
|
|
34
34
|
/**
|
|
35
|
-
* Asynchronously writes an object to a TOML file.
|
|
36
|
-
* @param path The path to the TOML file to write. Can be a file URL or a string path.
|
|
37
|
-
* @param data The data to serialize. Must be a plain object compatible with `smol-toml.stringify`.
|
|
38
|
-
* @param options Optional configuration for writing the TOML file. See {@link WriteTomlOptions}.
|
|
39
|
-
* @returns A promise that resolves when the TOML file has been written.
|
|
40
|
-
* @example
|
|
41
|
-
* ```javascript
|
|
42
|
-
* import { writeToml } from "@visulima/fs/toml";
|
|
43
|
-
* import { join } from "node:path";
|
|
44
|
-
*
|
|
45
|
-
* await writeToml(join("/tmp", "config.toml"), { name: "app", version: 1 });
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
35
|
+
* Asynchronously writes an object to a TOML file.
|
|
36
|
+
* @param path The path to the TOML file to write. Can be a file URL or a string path.
|
|
37
|
+
* @param data The data to serialize. Must be a plain object compatible with `smol-toml.stringify`.
|
|
38
|
+
* @param options Optional configuration for writing the TOML file. See {@link WriteTomlOptions}.
|
|
39
|
+
* @returns A promise that resolves when the TOML file has been written.
|
|
40
|
+
* @example
|
|
41
|
+
* ```javascript
|
|
42
|
+
* import { writeToml } from "@visulima/fs/toml";
|
|
43
|
+
* import { join } from "node:path";
|
|
44
|
+
*
|
|
45
|
+
* await writeToml(join("/tmp", "config.toml"), { name: "app", version: 1 });
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
48
|
declare const writeToml: (path: URL | string, data: Record<string, unknown>, options?: WriteTomlOptions) => Promise<void>;
|
|
49
49
|
/**
|
|
50
|
-
* Synchronously writes an object to a TOML file.
|
|
51
|
-
* @param path The path to the TOML file to write. Can be a file URL or a string path.
|
|
52
|
-
* @param data The data to serialize. Must be a plain object compatible with `smol-toml.stringify`.
|
|
53
|
-
* @param options Optional configuration for writing the TOML file. See {@link WriteTomlOptions}.
|
|
54
|
-
* @example
|
|
55
|
-
* ```javascript
|
|
56
|
-
* import { writeTomlSync } from "@visulima/fs/toml";
|
|
57
|
-
* import { join } from "node:path";
|
|
58
|
-
*
|
|
59
|
-
* writeTomlSync(join("/tmp", "config.toml"), { name: "app", version: 1 });
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
50
|
+
* Synchronously writes an object to a TOML file.
|
|
51
|
+
* @param path The path to the TOML file to write. Can be a file URL or a string path.
|
|
52
|
+
* @param data The data to serialize. Must be a plain object compatible with `smol-toml.stringify`.
|
|
53
|
+
* @param options Optional configuration for writing the TOML file. See {@link WriteTomlOptions}.
|
|
54
|
+
* @example
|
|
55
|
+
* ```javascript
|
|
56
|
+
* import { writeTomlSync } from "@visulima/fs/toml";
|
|
57
|
+
* import { join } from "node:path";
|
|
58
|
+
*
|
|
59
|
+
* writeTomlSync(join("/tmp", "config.toml"), { name: "app", version: 1 });
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
62
|
declare const writeTomlSync: (path: URL | string, data: Record<string, unknown>, options?: WriteTomlOptions) => void;
|
|
63
63
|
export { type ReadTomlOptions, type WriteTomlOptions, readToml, readTomlSync, writeToml, writeTomlSync };
|
package/dist/toml.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as r}from"./packem_shared/readToml-
|
|
1
|
+
import{default as r}from"./packem_shared/readToml-CN_xnICv.js";import{default as t}from"./packem_shared/readTomlSync-B9TVGzen.js";import{default as l}from"./packem_shared/writeToml-CrpfWNyK.js";import{default as d}from"./packem_shared/writeTomlSync-DveRchLG.js";export{r as readToml,t as readTomlSync,l as writeToml,d as writeTomlSync};
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
export { J as JSONError } from "./packem_shared/json-error.d-
|
|
1
|
+
export { J as JSONError } from "./packem_shared/json-error.d-COL8oxF_.js";
|
|
2
2
|
import { JsonValue } from 'type-fest';
|
|
3
|
-
import { k as CodeFrameOptions, l as JsonReviver } from "./packem_shared/types.d-
|
|
3
|
+
import { k as CodeFrameOptions, l as JsonReviver } from "./packem_shared/types.d-D3Jo_iA-.js";
|
|
4
4
|
export { toPath } from '@visulima/path/utils';
|
|
5
5
|
import 'node:fs';
|
|
6
6
|
import 'fdir';
|
|
7
7
|
/**
|
|
8
|
-
* Asserts that the provided contents are valid for writing to a file.
|
|
9
|
-
* Valid contents can be a string, an ArrayBuffer, or an ArrayBuffer view (e.g., Uint8Array).
|
|
10
|
-
* @param contents The file contents to validate.
|
|
11
|
-
* @throws {TypeError} If the contents are not a string, ArrayBuffer, or ArrayBuffer view.
|
|
12
|
-
* @example
|
|
13
|
-
* ```javascript
|
|
14
|
-
* import { assertValidFileContents } from "@visulima/fs"; // Assuming this util is exported
|
|
15
|
-
*
|
|
16
|
-
* try {
|
|
17
|
-
* assertValidFileContents("Hello, world!");
|
|
18
|
-
* assertValidFileContents(new Uint8Array([72, 101, 108, 108, 111])); // "Hello"
|
|
19
|
-
* assertValidFileContents(new ArrayBuffer(8));
|
|
20
|
-
* console.log("File contents are valid.");
|
|
21
|
-
* } catch (error) {
|
|
22
|
-
* console.error(error.message); // File contents must be a string, ArrayBuffer, or ArrayBuffer view.
|
|
23
|
-
* }
|
|
24
|
-
*
|
|
25
|
-
* try {
|
|
26
|
-
* assertValidFileContents(123); // Invalid content type
|
|
27
|
-
* } catch (error) {
|
|
28
|
-
* console.error(error.message); // File contents must be a string, ArrayBuffer, or ArrayBuffer view.
|
|
29
|
-
* }
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
8
|
+
* Asserts that the provided contents are valid for writing to a file.
|
|
9
|
+
* Valid contents can be a string, an ArrayBuffer, or an ArrayBuffer view (e.g., Uint8Array).
|
|
10
|
+
* @param contents The file contents to validate.
|
|
11
|
+
* @throws {TypeError} If the contents are not a string, ArrayBuffer, or ArrayBuffer view.
|
|
12
|
+
* @example
|
|
13
|
+
* ```javascript
|
|
14
|
+
* import { assertValidFileContents } from "@visulima/fs"; // Assuming this util is exported
|
|
15
|
+
*
|
|
16
|
+
* try {
|
|
17
|
+
* assertValidFileContents("Hello, world!");
|
|
18
|
+
* assertValidFileContents(new Uint8Array([72, 101, 108, 108, 111])); // "Hello"
|
|
19
|
+
* assertValidFileContents(new ArrayBuffer(8));
|
|
20
|
+
* console.log("File contents are valid.");
|
|
21
|
+
* } catch (error) {
|
|
22
|
+
* console.error(error.message); // File contents must be a string, ArrayBuffer, or ArrayBuffer view.
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* try {
|
|
26
|
+
* assertValidFileContents(123); // Invalid content type
|
|
27
|
+
* } catch (error) {
|
|
28
|
+
* console.error(error.message); // File contents must be a string, ArrayBuffer, or ArrayBuffer view.
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
32
|
declare const assertValidFileContents: (contents: any) => void;
|
|
33
33
|
/**
|
|
34
|
-
* Asserts that the provided path is a valid file or directory path.
|
|
35
|
-
* A valid path must be a non-empty string or a URL instance.
|
|
36
|
-
* @param fileOrDirectoryPath The path to validate.
|
|
37
|
-
* @throws {TypeError} If the path is not a non-empty string or a URL.
|
|
38
|
-
* @example
|
|
39
|
-
* ```javascript
|
|
40
|
-
* import { assertValidFileOrDirectoryPath } from "@visulima/fs"; // Assuming this util is exported
|
|
41
|
-
*
|
|
42
|
-
* try {
|
|
43
|
-
* assertValidFileOrDirectoryPath("/path/to/file.txt");
|
|
44
|
-
* assertValidFileOrDirectoryPath(new URL("file:///path/to/file.txt"));
|
|
45
|
-
* console.log("Path is valid.");
|
|
46
|
-
* } catch (error) {
|
|
47
|
-
* console.error(error.message); // Path must be a non-empty string or URL.
|
|
48
|
-
* }
|
|
49
|
-
*
|
|
50
|
-
* try {
|
|
51
|
-
* assertValidFileOrDirectoryPath(""); // Invalid path
|
|
52
|
-
* } catch (error) {
|
|
53
|
-
* console.error(error.message); // Path must be a non-empty string or URL.
|
|
54
|
-
* }
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
34
|
+
* Asserts that the provided path is a valid file or directory path.
|
|
35
|
+
* A valid path must be a non-empty string or a URL instance.
|
|
36
|
+
* @param fileOrDirectoryPath The path to validate.
|
|
37
|
+
* @throws {TypeError} If the path is not a non-empty string or a URL.
|
|
38
|
+
* @example
|
|
39
|
+
* ```javascript
|
|
40
|
+
* import { assertValidFileOrDirectoryPath } from "@visulima/fs"; // Assuming this util is exported
|
|
41
|
+
*
|
|
42
|
+
* try {
|
|
43
|
+
* assertValidFileOrDirectoryPath("/path/to/file.txt");
|
|
44
|
+
* assertValidFileOrDirectoryPath(new URL("file:///path/to/file.txt"));
|
|
45
|
+
* console.log("Path is valid.");
|
|
46
|
+
* } catch (error) {
|
|
47
|
+
* console.error(error.message); // Path must be a non-empty string or URL.
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* try {
|
|
51
|
+
* assertValidFileOrDirectoryPath(""); // Invalid path
|
|
52
|
+
* } catch (error) {
|
|
53
|
+
* console.error(error.message); // Path must be a non-empty string or URL.
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
57
|
declare const assertValidFileOrDirectoryPath: (fileOrDirectoryPath: any) => void;
|
|
58
58
|
declare function parseJson(string: string, filename?: string, options?: CodeFrameOptions): JsonValue;
|
|
59
59
|
declare function parseJson(string: string, reviver: JsonReviver, fileName?: string, options?: CodeFrameOptions): JsonValue;
|
|
60
60
|
/**
|
|
61
|
-
* Strips comments from a JSON string.
|
|
62
|
-
* Handles both single-line (//) and multi-line (/* ... *&#47;) comments.
|
|
63
|
-
* @param jsonString The JSON string possibly containing comments.
|
|
64
|
-
* @param [options] Optional configuration for stripping comments.
|
|
65
|
-
* @param [options.whitespace] If `true` (default), comments are replaced with whitespace to preserve line numbers and character positions. If `false`, comments are removed entirely.
|
|
66
|
-
* @returns The JSON string with comments stripped.
|
|
67
|
-
* @example
|
|
68
|
-
* ```javascript
|
|
69
|
-
* import { stripJsonComments } from "@visulima/fs"; // Assuming this util is exported
|
|
70
|
-
*
|
|
71
|
-
* const jsonWithComments = `{
|
|
72
|
-
* // This is a single-line comment
|
|
73
|
-
* "name": "John Doe",
|
|
74
|
-
* "age": 30, /* This is a
|
|
75
|
-
* multi-line comment */
|
|
76
|
-
* "city": "New York"
|
|
77
|
-
* }`;
|
|
78
|
-
*
|
|
79
|
-
* const stripped = stripJsonComments(jsonWithComments);
|
|
80
|
-
* console.log(stripped);
|
|
81
|
-
* // Output (with whitespace=true):
|
|
82
|
-
* // {
|
|
83
|
-
* //
|
|
84
|
-
* // "name": "John Doe",
|
|
85
|
-
* // "age": 30, /*
|
|
86
|
-
* //
|
|
87
|
-
* // "city": "New York"
|
|
88
|
-
* // }
|
|
89
|
-
*
|
|
90
|
-
* const strippedWithoutWhitespace = stripJsonComments(jsonWithComments, { whitespace: false });
|
|
91
|
-
* console.log(strippedWithoutWhitespace);
|
|
92
|
-
* // Output (with whitespace=false):
|
|
93
|
-
* // {
|
|
94
|
-
* // "name": "John Doe",
|
|
95
|
-
* // "age": 30,
|
|
96
|
-
* // "city": "New York"
|
|
97
|
-
* // }
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
61
|
+
* Strips comments from a JSON string.
|
|
62
|
+
* Handles both single-line (//) and multi-line (/* ... *&#47;) comments.
|
|
63
|
+
* @param jsonString The JSON string possibly containing comments.
|
|
64
|
+
* @param [options] Optional configuration for stripping comments.
|
|
65
|
+
* @param [options.whitespace] If `true` (default), comments are replaced with whitespace to preserve line numbers and character positions. If `false`, comments are removed entirely.
|
|
66
|
+
* @returns The JSON string with comments stripped.
|
|
67
|
+
* @example
|
|
68
|
+
* ```javascript
|
|
69
|
+
* import { stripJsonComments } from "@visulima/fs"; // Assuming this util is exported
|
|
70
|
+
*
|
|
71
|
+
* const jsonWithComments = `{
|
|
72
|
+
* // This is a single-line comment
|
|
73
|
+
* "name": "John Doe",
|
|
74
|
+
* "age": 30, /* This is a
|
|
75
|
+
* multi-line comment */
|
|
76
|
+
* "city": "New York"
|
|
77
|
+
* }`;
|
|
78
|
+
*
|
|
79
|
+
* const stripped = stripJsonComments(jsonWithComments);
|
|
80
|
+
* console.log(stripped);
|
|
81
|
+
* // Output (with whitespace=true):
|
|
82
|
+
* // {
|
|
83
|
+
* //
|
|
84
|
+
* // "name": "John Doe",
|
|
85
|
+
* // "age": 30, /*
|
|
86
|
+
* //
|
|
87
|
+
* // "city": "New York"
|
|
88
|
+
* // }
|
|
89
|
+
*
|
|
90
|
+
* const strippedWithoutWhitespace = stripJsonComments(jsonWithComments, { whitespace: false });
|
|
91
|
+
* console.log(strippedWithoutWhitespace);
|
|
92
|
+
* // Output (with whitespace=false):
|
|
93
|
+
* // {
|
|
94
|
+
* // "name": "John Doe",
|
|
95
|
+
* // "age": 30,
|
|
96
|
+
* // "city": "New York"
|
|
97
|
+
* // }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
100
|
declare const stripJsonComments: (jsonString: string, options?: {
|
|
101
101
|
whitespace?: boolean;
|
|
102
102
|
}) => string;
|
package/dist/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as e}from"./packem_shared/JSONError-Cvp9ycba.js";import{default as a}from"./packem_shared/assertValidFileContents-CbIN7sy7.js";import{default as f}from"./packem_shared/assertValidFileOrDirectoryPath-BTlt945W.js";import{default as m}from"./packem_shared/parseJson-
|
|
1
|
+
import{default as e}from"./packem_shared/JSONError-Cvp9ycba.js";import{default as a}from"./packem_shared/assertValidFileContents-CbIN7sy7.js";import{default as f}from"./packem_shared/assertValidFileOrDirectoryPath-BTlt945W.js";import{default as m}from"./packem_shared/parseJson-_OfIPruP.js";import{default as d}from"./packem_shared/stripJsonComments-Bfcn2PKv.js";import{toPath as x}from"@visulima/path/utils";export{e as JSONError,a as assertValidFileContents,f as assertValidFileOrDirectoryPath,m as parseJson,d as stripJsonComments,x as toPath};
|
package/dist/yaml.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CompressionType, m as ReadYamlOptions, Y as YamlReviver, n as WriteYamlOptions, o as JsonReplacer } from "./packem_shared/types.d-
|
|
2
|
-
export type { p as YamlReplacer } from "./packem_shared/types.d-
|
|
1
|
+
import { C as CompressionType, m as ReadYamlOptions, Y as YamlReviver, n as WriteYamlOptions, o as JsonReplacer } from "./packem_shared/types.d-D3Jo_iA-.js";
|
|
2
|
+
export type { p as YamlReplacer } from "./packem_shared/types.d-D3Jo_iA-.js";
|
|
3
3
|
import 'node:fs';
|
|
4
4
|
import 'fdir';
|
|
5
5
|
declare function readYaml<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<CompressionType>): Promise<R>;
|
package/dist/yaml.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as r}from"./packem_shared/readYaml-
|
|
1
|
+
import{default as r}from"./packem_shared/readYaml-DcpUq11D.js";import{default as f}from"./packem_shared/readYamlSync-D5RVZwco.js";import{default as m}from"./packem_shared/writeYaml-DvSQ_Jbn.js";import{default as d}from"./packem_shared/writeYamlSync-CEf0PUGQ.js";export{r as readYaml,f as readYamlSync,m as writeYaml,d as writeYamlSync};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as v}from"node:module";import{toPath as n}from"@visulima/path/utils";import h from"./AlreadyExistsError-DEb3UWja.js";import c from"./assertValidFileOrDirectoryPath-BTlt945W.js";const y=v(import.meta.url),s=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=r=>{if(typeof s<"u"&&s.versions&&s.versions.node){const[e,t]=s.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return s.getBuiltinModule(r)}return y(r)},{cp:g}=b("node:fs/promises"),x=async(r,e,t={})=>{c(r),c(e);const{dereference:a=!1,errorOnExist:f=!0,filter:m,overwrite:p=!0,preserveTimestamps:l=!1,recursive:u=!0,verbatimSymlinks:d=!1}=t,_=n(r),o=n(e);try{await g(_,o,{dereference:a,errorOnExist:f,filter:m,force:p,preserveTimestamps:l,recursive:u,verbatimSymlinks:d})}catch(i){throw i?.code==="ERR_FS_CP_EEXIST"?new h(`destination already exists, copy '${o}'`):i}};export{x as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as v}from"node:module";import{toPath as n}from"@visulima/path/utils";import g from"./AlreadyExistsError-DEb3UWja.js";import c from"./assertValidFileOrDirectoryPath-BTlt945W.js";const y=v(import.meta.url),s=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=r=>{if(typeof s<"u"&&s.versions&&s.versions.node){const[e,t]=s.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return s.getBuiltinModule(r)}return y(r)},{cpSync:b}=h("node:fs"),x=(r,e,t={})=>{c(r),c(e);const{dereference:a=!1,errorOnExist:f=!0,filter:m,overwrite:l=!0,preserveTimestamps:p=!1,recursive:u=!0,verbatimSymlinks:d=!1}=t,_=n(r),o=n(e);try{b(_,o,{dereference:a,errorOnExist:f,filter:m,force:l,preserveTimestamps:p,recursive:u,verbatimSymlinks:d})}catch(i){throw i?.code==="ERR_FS_CP_EEXIST"?new g(`destination already exists, copy '${o}'`):i}};export{x as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as c}from"node:module";import{join as d}from"@visulima/path";import{toPath as l}from"@visulima/path/utils";import _ from"./assertValidFileOrDirectoryPath-BTlt945W.js";import{t as g}from"./build-rm-options-avnusYx-.js";const a=c(import.meta.url),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,i=e=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[o,s]=r.versions.node.split(".").map(Number);if(o>22||o===22&&s>=3||o===20&&s>=16)return r.getBuiltinModule(e)}return a(e)},{existsSync:f}=i("node:fs"),{mkdir:m,readdir:u,rm:p}=i("node:fs/promises"),q=async(e,o)=>{if(_(e),!f(e)){await m(e,{recursive:!0});return}const s=await u(e),t=g(o);for(const n of s)await p(d(l(e),n),t)};export{q as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as n}from"node:module";import{join as a}from"@visulima/path";import{toPath as d}from"@visulima/path/utils";import l from"./assertValidFileOrDirectoryPath-BTlt945W.js";import{t as _}from"./build-rm-options-avnusYx-.js";const t=n(import.meta.url),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,c=e=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[o,s]=r.versions.node.split(".").map(Number);if(o>22||o===22&&s>=3||o===20&&s>=16)return r.getBuiltinModule(e)}return t(e)},{existsSync:f,mkdirSync:m,readdirSync:u,rmSync:p}=c("node:fs"),v=(e,o)=>{if(l(e),!f(e)){m(e,{recursive:!0});return}const s=_(o);for(const i of u(e))p(a(d(e),i),s)};export{v as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as n}from"node:module";import p from"./assertValidFileOrDirectoryPath-BTlt945W.js";import{g as i}from"./get-file-info-type-DzWpohDB.js";const c=n(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,a=r=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[e,t]=o.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return o.getBuiltinModule(r)}return c(r)},{lstat:s,mkdir:u}=a("node:fs/promises"),m=async r=>{p(r);try{const e=await s(r);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(i(e))}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{await u(r,{recursive:!0})}catch(e){if(e.code!=="EEXIST")throw e;const t=await s(r);if(!t.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(i(t))}'`,{cause:e})}};export{m as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as n}from"node:module";import d from"./assertValidFileOrDirectoryPath-BTlt945W.js";import{g as i}from"./get-file-info-type-DzWpohDB.js";const c=n(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,u=r=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[e,t]=o.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return o.getBuiltinModule(r)}return c(r)},{lstatSync:s,mkdirSync:a}=u("node:fs"),g=r=>{d(r);try{const e=s(r);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(i(e))}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{a(r,{recursive:!0})}catch(e){if(e.code!=="EEXIST")throw e;const t=s(r);if(!t.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(i(t))}'`,{cause:e})}};export{g as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as i}from"node:module";import{dirname as p}from"@visulima/path";import{toPath as f}from"@visulima/path/utils";import m from"./assertValidFileOrDirectoryPath-BTlt945W.js";import l from"./ensureDir-DGarVZw8.js";import{g as u}from"./get-file-info-type-DzWpohDB.js";const s=i(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,n=r=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[e,t]=o.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return o.getBuiltinModule(r)}return s(r)},{lstat:a,writeFile:c}=n("node:fs/promises"),j=async r=>{m(r);try{const e=await a(r);if(!e.isFile())throw new Error(`Ensure path exists, expected 'file', got '${String(u(e))}'`)}catch(e){if(e.code==="ENOENT"){await l(p(f(r))),await c(r,new Uint8Array);return}throw e}};export{j as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as i}from"node:module";import{dirname as p}from"@visulima/path";import{toPath as a}from"@visulima/path/utils";import m from"./assertValidFileOrDirectoryPath-BTlt945W.js";import l from"./ensureDirSync-CsgPrsDH.js";import{g as u}from"./get-file-info-type-DzWpohDB.js";const s=i(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,n=r=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[e,t]=o.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return o.getBuiltinModule(r)}return s(r)},{lstatSync:c,writeFileSync:f}=n("node:fs"),w=r=>{m(r);try{const e=c(r);if(!e.isFile())throw new Error(`Ensure path exists, expected 'file', got '${String(u(e))}'`)}catch(e){if(e.code==="ENOENT"){l(p(a(r))),f(r,new Uint8Array);return}throw e}};export{w as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as p}from"node:module";import{toNamespacedPath as n,dirname as _}from"@visulima/path";import{toPath as c}from"@visulima/path/utils";import m from"./assertValidFileOrDirectoryPath-BTlt945W.js";import g from"./ensureDir-DGarVZw8.js";import{d as h}from"./is-stats-identical-l1GRN4Qu.js";const f=p(import.meta.url),s=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,u=o=>{if(typeof s<"u"&&s.versions&&s.versions.node){const[e,t]=s.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return s.getBuiltinModule(o)}return f(o)},{lstat:a,link:d}=u("node:fs/promises"),P=async(o,e)=>{m(o),m(e),o=n(c(o)),e=n(c(e));let t;try{t=await a(e)}catch{}let i;try{i=await a(o)}catch(l){const r=l;throw r.message=r.message.replace("lstat","ensureLink"),r}t&&h(i,t)||(await g(_(e)),await d(o,e))};export{P as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as p}from"node:module";import{toNamespacedPath as c,dirname as _}from"@visulima/path";import{toPath as a}from"@visulima/path/utils";import m from"./assertValidFileOrDirectoryPath-BTlt945W.js";import g from"./ensureDirSync-CsgPrsDH.js";import{d as h}from"./is-stats-identical-l1GRN4Qu.js";const f=p(import.meta.url),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,u=o=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[e,s]=t.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return t.getBuiltinModule(o)}return f(o)},{lstatSync:i,linkSync:d}=u("node:fs"),T=(o,e)=>{m(o),m(e),o=c(a(o)),e=c(a(e));let s;try{s=i(e)}catch{}let n;try{n=i(o)}catch(l){const r=l;throw r.message=r.message.replace("lstat","ensureLink"),r}s&&h(n,s)||(g(_(e)),d(o,e))};export{T as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as _}from"node:module";import{toNamespacedPath as m,dirname as v,resolve as P}from"@visulima/path";import{toPath as p}from"@visulima/path/utils";import d from"./assertValidFileOrDirectoryPath-BTlt945W.js";import S from"./ensureDir-DGarVZw8.js";import{g as u}from"./get-file-info-type-DzWpohDB.js";import{d as x}from"./is-stats-identical-l1GRN4Qu.js";import{t as q}from"./resolve-symlink-target-CWrn0v4P.js";import w from"./AlreadyExistsError-DEb3UWja.js";const b=_(import.meta.url),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=i=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[e,o]=t.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return t.getBuiltinModule(i)}return b(i)},{lstat:c,stat:f,symlink:T,readlink:k}=j("node:fs/promises"),E=process.platform==="win32"||/^(?:msys|cygwin)$/.test(process.env.OSTYPE),X=async(i,e,o)=>{d(i),d(e);const r=q(i,e);e=m(p(e));try{if((await c(e)).isSymbolicLink()){const[s,n]=await Promise.all([f(r),f(e)]);if(x(s,n))return}}catch{}const y=await c(r),h=u(y);await S(v(e));let a=o??"file";o||(E?a="junction":a=h==="dir"?"dir":"file");try{await T(m(p(r)),e,a)}catch(s){if(s.code!=="EEXIST")throw s;const n=await c(e);if(!n.isSymbolicLink())throw new w(`A ${String(u(n))} already exists at the path: ${e}`);const g=await k(e),l=m(P(g));if(l!==r)throw new w(`A symlink targeting to an undesired path already exists: ${e} -> ${l}`)}};export{X as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as w}from"node:module";import{toNamespacedPath as f,dirname as v,resolve as x}from"@visulima/path";import{toPath as p}from"@visulima/path/utils";import d from"./assertValidFileOrDirectoryPath-BTlt945W.js";import P from"./ensureDirSync-CsgPrsDH.js";import{g as u}from"./get-file-info-type-DzWpohDB.js";import{d as y}from"./is-stats-identical-l1GRN4Qu.js";import{t as q}from"./resolve-symlink-target-CWrn0v4P.js";import g from"./AlreadyExistsError-DEb3UWja.js";const b=w(import.meta.url),s=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=o=>{if(typeof s<"u"&&s.versions&&s.versions.node){const[e,r]=s.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return s.getBuiltinModule(o)}return b(o)},{lstatSync:m,statSync:c,symlinkSync:T,readlinkSync:k}=j("node:fs"),E=process.platform==="win32"||/^(?:msys|cygwin)$/.test(process.env.OSTYPE),X=(o,e,r)=>{d(o),d(e);const i=q(o,e);e=f(p(e));try{if(m(e).isSymbolicLink()&&y(c(i),c(e))){const t=c(i),n=c(e);if(y(t,n))return}}catch{}const h=m(i),_=u(h);P(v(e));let a=r??"file";r||(E?a="junction":a=_==="dir"?"dir":"file");try{T(f(p(i)),e,a)}catch(t){if(t.code!=="EEXIST")throw t;const n=m(e);if(!n.isSymbolicLink())throw new g(`A ${String(u(n))} already exists at the path: ${e}`);const S=k(e),l=f(x(S));if(l!==i)throw new g(`A symlink targeting to an undesired path already exists: ${e} -> ${l}`)}};export{X as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as g}from"node:module";import{resolve as c,parse as T,isAbsolute as j,dirname as v}from"@visulima/path";import{toPath as f}from"@visulima/path/utils";import{FIND_UP_STOP as B}from"./FIND_UP_STOP-CAwY1qU7.js";const w=g(import.meta.url),s=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=t=>{if(typeof s<"u"&&s.versions&&s.versions.node){const[e,i]=s.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return s.getBuiltinModule(t)}return w(t)},{stat:A,lstat:b}=h("node:fs/promises"),k=async(t,e={})=>{if(typeof t!="string"&&!Array.isArray(t)&&typeof t!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");const i=e.cwd?f(e.cwd):process.cwd();let r=c(i);const{root:a}=T(r),y=f(e.stopAt??a),m=c(r,y),u=e.type??"file",d=async function(n){return typeof t=="function"?[await t(n)]:typeof t=="string"?[t]:Array.isArray(t)?t:[t]};e.allowSymlinks??=!0;const _=e.allowSymlinks?A:b;for(;r&&r!==m&&r!==a;){const n=await d(r);for(let o of n){if(o===B)return;if(o===void 0)continue;Buffer.isBuffer(o)?o=o.toString():o instanceof URL&&(o=f(o));const l=j(o)?o:c(r,o);try{const p=await _(l);if(u==="file"&&p.isFile()||u==="directory"&&p.isDirectory())return l}catch{}}r=v(r)}};export{k as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as _}from"node:module";import{resolve as i,parse as A,isAbsolute as S,dirname as T}from"@visulima/path";import{toPath as c}from"@visulima/path/utils";import{FIND_UP_STOP as j}from"./FIND_UP_STOP-CAwY1qU7.js";const g=_(import.meta.url),s=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=e=>{if(typeof s<"u"&&s.versions&&s.versions.node){const[o,n]=s.versions.node.split(".").map(Number);if(o>22||o===22&&n>=3||o===20&&n>=16)return s.getBuiltinModule(e)}return g(e)},{statSync:w,lstatSync:b}=h("node:fs"),F=(e,o={})=>{if(typeof e!="string"&&!Array.isArray(e)&&typeof e!="function")throw new TypeError("The `name` argument must be of type `string` or `string[]`");const n=o.cwd?c(o.cwd):process.cwd();let r=i(n);const{root:f}=A(r),p=c(o.stopAt??f),y=i(r,p),u=o.type??"file",m=function(t){return typeof e=="function"?[e(t)]:typeof e=="string"?[e]:Array.isArray(e)?e:[e]};o.allowSymlinks??=!0;const d=o.allowSymlinks?w:b;for(;r&&r!==y&&r!==f;){for(let t of m(r)){if(t===j)return;if(t===void 0)continue;Buffer.isBuffer(t)?t=t.toString():t instanceof URL&&(t=c(t));const a=S(t)?t:i(r,t);try{const l=d(a);if(u==="file"&&l.isFile()||u==="directory"&&l.isDirectory())return a}catch{}}r=T(r)}};export{F as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as o}from"./index-Ct4GqZSP.js";const i=async(a,t)=>await o(a,t);export{i as default};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { G as GlobOptions } from "./types.d-BMdL_ygj.js";
|
|
2
|
-
/**
|
|
3
|
-
* Asynchronously matches files on disk using one or more glob patterns.
|
|
4
|
-
*
|
|
5
|
-
* Powered by [`tinyglobby`](https://github.com/SuperchupuDev/tinyglobby); `tinyglobby` is bundled into the
|
|
6
|
-
* built output so it does not appear as a runtime dependency of `@visulima/fs`.
|
|
7
|
-
*
|
|
8
|
-
* Pattern forms:
|
|
9
|
-
*
|
|
10
|
-
* - Plain glob — `src/**\/*.ts`
|
|
11
|
-
* - Negated pattern — `!src/**\/*.spec.ts` inside `patterns` adds to the internal ignore list (same as passing it via `ignore`).
|
|
12
|
-
* - Negated ignore — a leading `!` inside {@link GlobOptions.ignore} _un-ignores_ entries that an earlier ignore pattern would drop, e.g. `ignore: ["dist/**", "!dist/index.d.ts"]`.
|
|
13
|
-
* @param patterns A single glob pattern or an array of glob patterns.
|
|
14
|
-
* @param options Optional glob options. See {@link GlobOptions}.
|
|
15
|
-
* @returns A promise resolving to the array of matched paths. Paths are relative to {@link GlobOptions.cwd} unless {@link GlobOptions.absolute} is `true`.
|
|
16
|
-
* @example
|
|
17
|
-
* ```javascript
|
|
18
|
-
* import { glob } from "@visulima/fs";
|
|
19
|
-
*
|
|
20
|
-
* const jsFiles = await glob("src/**\/*.{js,ts}", { cwd: process.cwd(), ignore: ["**\/node_modules/**"] });
|
|
21
|
-
* console.log(jsFiles);
|
|
22
|
-
*
|
|
23
|
-
* // Negated ignore: drop everything under `ignored/` except `ignored/keep.ts`.
|
|
24
|
-
* const keep = await glob("**\/*.ts", { ignore: ["ignored/**", "!ignored/keep.ts"] });
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
declare const glob: (patterns: string | ReadonlyArray<string>, options?: GlobOptions) => Promise<string[]>;
|
|
28
|
-
/**
|
|
29
|
-
* Synchronously matches files on disk using one or more glob patterns.
|
|
30
|
-
*
|
|
31
|
-
* Synchronous counterpart of `glob`. Powered by [`tinyglobby`](https://github.com/SuperchupuDev/tinyglobby);
|
|
32
|
-
* bundled into the built output so it does not appear as a runtime dependency of `@visulima/fs`.
|
|
33
|
-
*
|
|
34
|
-
* Pattern forms:
|
|
35
|
-
*
|
|
36
|
-
* - Plain glob — `src/**\/*.ts`
|
|
37
|
-
* - Negated pattern — `!src/**\/*.spec.ts` inside `patterns` adds to the internal ignore list.
|
|
38
|
-
* - Negated ignore — a leading `!` inside {@link GlobOptions.ignore} _un-ignores_ entries that an earlier ignore pattern would drop, e.g. `ignore: ["dist/**", "!dist/index.d.ts"]`.
|
|
39
|
-
* @param patterns A single glob pattern or an array of glob patterns.
|
|
40
|
-
* @param options Optional glob options. See {@link GlobOptions}.
|
|
41
|
-
* @returns The array of matched paths. Paths are relative to {@link GlobOptions.cwd} unless {@link GlobOptions.absolute} is `true`.
|
|
42
|
-
* @example
|
|
43
|
-
* ```javascript
|
|
44
|
-
* import { globSync } from "@visulima/fs";
|
|
45
|
-
*
|
|
46
|
-
* const jsFiles = globSync(["src/**\/*.ts", "!**\/*.spec.ts"]);
|
|
47
|
-
* console.log(jsFiles);
|
|
48
|
-
*
|
|
49
|
-
* // Negated ignore: drop everything under `ignored/` except `ignored/keep.ts`.
|
|
50
|
-
* const keep = globSync("**\/*.ts", { ignore: ["ignored/**", "!ignored/keep.ts"] });
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
declare const globSync: (patterns: string | ReadonlyArray<string>, options?: GlobOptions) => string[];
|
|
54
|
-
export { globSync as a, glob as g };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as r}from"./index-Ct4GqZSP.js";const s=(t,o)=>r(t,o);export{s as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as it}from"node:module";import{a as $}from"./index-LUKYN3u3.js";const ut=it(import.meta.url),P=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=t=>{if(typeof P<"u"&&P.versions&&P.versions.node){const[e,s]=P.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return P.getBuiltinModule(t)}return ut(t)},R=D("fs"),lt={...R,default:R},{statSync:ct,stat:at,realpathSync:ht,realpath:pt,readdirSync:ft,readdir:gt}=D("fs"),{sep:G,basename:dt,dirname:A,resolve:N,normalize:yt,relative:mt,posix:S,isAbsolute:bt}=D("path"),{fileURLToPath:vt}=D("url"),{createRequire:wt}=D("module");var C=wt(import.meta.url);function St(t){let e=yt(t);return e.length>1&&e[e.length-1]===G&&(e=e.substring(0,e.length-1)),e}const $t=/[\\/]/g;function U(t,e){return t.replace($t,e)}const kt=/^[a-z]:[\\/]$/i;function Pt(t){return t==="/"||kt.test(t)}function j(t,e){const{resolvePaths:s,normalizePath:r,pathSeparator:n}=e,i=process.platform==="win32"&&t.includes("/")||t.startsWith(".");if(s&&(t=N(t)),(r||i)&&(t=St(t)),t===".")return"";const o=t[t.length-1]!==n;return U(o?t+n:t,n)}function Q(t,e){return e+t}function xt(t,e){return function(s,r){return r.startsWith(t)?r.slice(t.length)+s:U(mt(t,r),e.pathSeparator)+e.pathSeparator+s}}function Dt(t){return t}function Ft(t,e,s){return e+t+s}function _t(t,e){const{relativePaths:s,includeBasePath:r}=e;return s&&t?xt(t,e):r?Q:Dt}function Et(t){return function(e,s){s.push(e.substring(t.length)||".")}}function qt(t){return function(e,s,r){const n=e.substring(t.length)||".";r.every(i=>i(n,!0))&&s.push(n)}}const jt=(t,e)=>{e.push(t||".")},Ot=(t,e,s)=>{const r=t||".";s.every(n=>n(r,!0))&&e.push(r)},At=()=>{};function Wt(t,e){const{includeDirs:s,filters:r,relativePaths:n}=e;return s?n?r&&r.length?qt(t):Et(t):r&&r.length?Ot:jt:At}const Bt=(t,e,s,r)=>{r.every(n=>n(t,!1))&&s.files++},Rt=(t,e,s,r)=>{r.every(n=>n(t,!1))&&e.push(t)},Ct=(t,e,s,r)=>{s.files++},Mt=(t,e)=>{e.push(t)},Lt=()=>{};function It(t){const{excludeFiles:e,filters:s,onlyCounts:r}=t;return e?Lt:s&&s.length?r?Bt:Rt:r?Ct:Mt}const Tt=t=>t,zt=()=>[""].slice(0,0);function Gt(t){return t.group?zt:Tt}const Nt=(t,e,s)=>{t.push({directory:e,files:s,dir:e})},Ut=()=>{};function Qt(t){return t.group?Nt:Ut}const Yt=function(t,e,s){const{queue:r,fs:n,options:{suppressErrors:i}}=e;r.enqueue(),n.realpath(t,(o,u)=>{if(o)return r.dequeue(i?null:o,e);n.stat(u,(g,f)=>{if(g)return r.dequeue(i?null:g,e);if(f.isDirectory()&&Y(t,u,e))return r.dequeue(null,e);s(f,u),r.dequeue(null,e)})})},Zt=function(t,e,s){const{queue:r,fs:n,options:{suppressErrors:i}}=e;r.enqueue();try{const o=n.realpathSync(t),u=n.statSync(o);if(u.isDirectory()&&Y(t,o,e))return;s(u,o)}catch(o){if(!i)throw o}};function Ht(t,e){return!t.resolveSymlinks||t.excludeSymlinks?null:e?Zt:Yt}function Y(t,e,s){if(s.options.useRealPaths)return Jt(e,s);let r=A(t),n=1;for(;r!==s.root&&n<2;){const i=s.symlinks.get(r);i&&(i===e||i.startsWith(e)||e.startsWith(i))?n++:r=A(r)}return s.symlinks.set(t,e),n>1}function Jt(t,e){return e.visited.includes(t+e.options.pathSeparator)}const Kt=t=>t.counts,Vt=t=>t.groups,Xt=t=>t.paths,te=t=>t.paths.slice(0,t.options.maxFiles),ee=(t,e,s)=>(F(e,s,t.counts,t.options.suppressErrors),null),se=(t,e,s)=>(F(e,s,t.paths,t.options.suppressErrors),null),re=(t,e,s)=>(F(e,s,t.paths.slice(0,t.options.maxFiles),t.options.suppressErrors),null),ne=(t,e,s)=>(F(e,s,t.groups,t.options.suppressErrors),null);function F(t,e,s,r){e(t&&!r?t:null,s)}function oe(t,e){const{onlyCounts:s,group:r,maxFiles:n}=t;return s?e?Kt:ee:r?e?Vt:ne:n?e?te:re:e?Xt:se}const Z={withFileTypes:!0},ie=(t,e,s,r,n)=>{if(t.queue.enqueue(),r<0)return t.queue.dequeue(null,t);const{fs:i}=t;t.visited.push(e),t.counts.directories++,i.readdir(e||".",Z,(o,u=[])=>{n(u,s,r),t.queue.dequeue(t.options.suppressErrors?null:o,t)})},ue=(t,e,s,r,n)=>{const{fs:i}=t;if(r<0)return;t.visited.push(e),t.counts.directories++;let o=[];try{o=i.readdirSync(e||".",Z)}catch(u){if(!t.options.suppressErrors)throw u}n(o,s,r)};function le(t){return t?ue:ie}var ce=class{count=0;constructor(t){this.onQueueEmpty=t}enqueue(){return this.count++,this.count}dequeue(t,e){this.onQueueEmpty&&(--this.count<=0||t)&&(this.onQueueEmpty(t,e),t&&(e.controller.abort(),this.onQueueEmpty=void 0))}},ae=class{_files=0;_directories=0;set files(t){this._files=t}get files(){return this._files}set directories(t){this._directories=t}get directories(){return this._directories}get dirs(){return this._directories}},he=class{aborted=!1;abort(){this.aborted=!0}},H=class{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(t,e,s){this.isSynchronous=!s,this.callbackInvoker=oe(e,this.isSynchronous),this.root=j(t,e),this.state={root:Pt(this.root)?this.root:this.root.slice(0,-1),paths:[""].slice(0,0),groups:[],counts:new ae,options:e,queue:new ce((r,n)=>this.callbackInvoker(n,r,s)),symlinks:new Map,visited:[""].slice(0,0),controller:new he,fs:e.fs||lt},this.joinPath=_t(this.root,e),this.pushDirectory=Wt(this.root,e),this.pushFile=It(e),this.getArray=Gt(e),this.groupFiles=Qt(e),this.resolveSymlink=Ht(e,this.isSynchronous),this.walkDirectory=le(this.isSynchronous)}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(t,e,s)=>{const{paths:r,options:{filters:n,resolveSymlinks:i,excludeSymlinks:o,exclude:u,maxFiles:g,signal:f,useRealPaths:y,pathSeparator:h},controller:m}=this.state;if(m.aborted||f&&f.aborted||g&&r.length>g)return;const l=this.getArray(this.state.paths);for(let p=0;p<t.length;++p){const a=t[p];if(a.isFile()||a.isSymbolicLink()&&!i&&!o){const c=this.joinPath(a.name,e);this.pushFile(c,l,this.state.counts,n)}else if(a.isDirectory()){let c=Ft(a.name,e,this.state.options.pathSeparator);if(u&&u(a.name,c))continue;this.pushDirectory(c,r,n),this.walkDirectory(this.state,c,c,s-1,this.walk)}else if(this.resolveSymlink&&a.isSymbolicLink()){let c=Q(a.name,e);this.resolveSymlink(c,this.state,(_,d)=>{if(_.isDirectory()){if(d=j(d,this.state.options),u&&u(a.name,y?d:c+h))return;this.walkDirectory(this.state,d,y?d:c+h,s-1,this.walk)}else{d=y?d:c;const k=dt(d),E=j(A(d),this.state.options);d=this.joinPath(k,E),this.pushFile(d,l,this.state.counts,n)}})}}this.groupFiles(this.state.groups,e,l)}};function pe(t,e){return new Promise((s,r)=>{J(t,e,(n,i)=>{if(n)return r(n);s(i)})})}function J(t,e,s){new H(t,e,s).start()}function fe(t,e){return new H(t,e).start()}var M=class{constructor(e,s){this.root=e,this.options=s}withPromise(){return pe(this.root,this.options)}withCallback(e){J(this.root,this.options,e)}sync(){return fe(this.root,this.options)}};let K=null;try{C.resolve("picomatch"),K=C("picomatch")}catch{}var ge=class{globCache={};options={maxDepth:1/0,suppressErrors:!0,pathSeparator:G,filters:[]};globFunction;constructor(t){this.options={...this.options,...t},this.globFunction=this.options.globFunction}group(){return this.options.group=!0,this}withPathSeparator(t){return this.options.pathSeparator=t,this}withBasePath(){return this.options.includeBasePath=!0,this}withRelativePaths(){return this.options.relativePaths=!0,this}withDirs(){return this.options.includeDirs=!0,this}withMaxDepth(t){return this.options.maxDepth=t,this}withMaxFiles(t){return this.options.maxFiles=t,this}withFullPaths(){return this.options.resolvePaths=!0,this.options.includeBasePath=!0,this}withErrors(){return this.options.suppressErrors=!1,this}withSymlinks({resolvePaths:t=!0}={}){return this.options.resolveSymlinks=!0,this.options.useRealPaths=t,this.withFullPaths()}withAbortSignal(t){return this.options.signal=t,this}normalize(){return this.options.normalizePath=!0,this}filter(t){return this.options.filters.push(t),this}onlyDirs(){return this.options.excludeFiles=!0,this.options.includeDirs=!0,this}exclude(t){return this.options.exclude=t,this}onlyCounts(){return this.options.onlyCounts=!0,this}crawl(t){return new M(t||".",this.options)}withGlobFunction(t){return this.globFunction=t,this}crawlWithOptions(t,e){return this.options={...this.options,...e},new M(t||".",this.options)}glob(...t){return this.globFunction?this.globWithOptions(t):this.globWithOptions(t,{dot:!0})}globWithOptions(t,...e){const s=this.globFunction||K;if(!s)throw new Error("Please specify a glob function to use glob matching.");var r=this.globCache[t.join("\0")];return r||(r=s(t,...e),this.globCache[t.join("\0")]=r),this.options.filters.push(n=>r(n)),this}};const de=Array.isArray,V=/\\/g,ye=/^[A-Za-z]:$/,X=process.platform==="win32",me=/^(\/?\.\.)+$/;function L(t,e={}){const s=t.length,r=Array(s),n=Array(s);let i,o;for(i=0;i<s;i++){const u=tt(t[i]);r[i]=u;const g=u.length,f=Array(g);for(o=0;o<g;o++)f[o]=$(u[o],e);n[i]=f}return u=>{const g=u.split("/");if(g[0]===".."&&me.test(u))return!0;for(i=0;i<s;i++){const f=r[i],y=n[i],h=g.length,m=Math.min(h,f.length);for(o=0;o<m;){const l=f[o];if(l.includes("/"))return!0;if(!y[o](g[o]))break;if(!e.noglobstar&&l==="**")return!0;o++}if(o===h)return!0}return!1}}const be=/^[A-Z]:\/$/i,ve=X?t=>be.test(t):t=>t==="/";function I(t,e,s){if(t===e||e.startsWith(`${t}/`)){if(s){const n=t.length+ +!ve(t);return(i,o)=>i.slice(n,o?-1:void 0)||"."}const r=e.slice(t.length+1);return r?(n,i)=>{if(n===".")return r;const o=`${r}/${n}`;return i?o.slice(0,-1):o}:(n,i)=>i&&n!=="."?n.slice(0,-1):n}return s?r=>S.relative(t,r)||".":r=>S.relative(t,`${e}/${r}`)||"."}function we(t,e){if(e.startsWith(`${t}/`)){const s=e.slice(t.length+1);return r=>`${s}/${r}`}return s=>{const r=S.relative(t,`${e}/${s}`);return s[s.length-1]==="/"&&r!==""?`${r}/`:r||"."}}function T(t){return t.replace(ye,e=>`${e}/`)}const Se={parts:!0};function tt(t){var e;const s=$.scan(t,Se);return!((e=s.parts)===null||e===void 0)&&e.length?s.parts:[t]}const $e=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,ke=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,Pe=t=>t.replace($e,"\\$&"),xe=t=>t.replace(ke,"\\$&"),De=X?xe:Pe;function Fe(t,e){const s=$.scan(t);return s.isGlob||s.negated}function x(...t){console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`,...t)}function et(t){return typeof t=="string"?[t]:t??[]}const _e=/^(\/?\.\.)+/,Ee=/\\(?=[()[\]{}!*+?@|])/g;function O(t,e,s,r){var n;const i=e.cwd;let o=t;t[t.length-1]==="/"&&(o=t.slice(0,-1));const u=o.lastIndexOf("/"),g=(u===-1?o:o.slice(u+1)).startsWith("!(");o[o.length-1]!=="*"&&!g&&e.expandDirectories&&(o+="/**");const f=De(i);o=bt(o.replace(Ee,""))?S.relative(f,o):S.normalize(o);const y=(n=_e.exec(o))===null||n===void 0?void 0:n[0],h=tt(o);if(y){const l=(y.length+1)/3;let p=0;const a=f.split("/");for(;p<l&&h[p+l]===a[a.length+p-l];)o=o.slice(0,(l-p-1)*3)+o.slice((l-p)*3+h[p+l].length+1)||".",p++;const c=S.join(i,y.slice(p*3));c[0]!=="."&&s.root.length>c.length&&(s.root=T(c),s.depthOffset=-l+p)}if(!r&&s.depthOffset>=0){var m;(m=s.commonPath)!==null&&m!==void 0||(s.commonPath=h);const l=[],p=Math.min(s.commonPath.length,h.length);for(let a=0;a<p;a++){const c=h[a];if(c==="**"&&!h[a+1]){l.pop();break}if(a===h.length-1||c!==s.commonPath[a]||Fe(c))break;l.push(c)}s.depthOffset=l.length,s.commonPath=l,s.root=T(l.length>0?S.join(i,...l):i)}return o}function qe(t,e,s){const r=[],n=[],i=[];for(const o of t.ignore)o&&(o[0]!=="!"||o[1]==="("?n.push(O(o,t,s,!0)):i.push(o.slice(1)));for(const o of e)o&&(o[0]!=="!"||o[1]==="("?r.push(O(o,t,s,!1)):(o[1]!=="!"||o[2]==="(")&&n.push(O(o.slice(1),t,s,!0)));return{match:r,ignore:n,unignore:i}}function je(t,e){const s=t.cwd,r={root:s,depthOffset:0},n=qe(t,e,r);t.debug&&x("internal processing patterns:",n);const{absolute:i,caseSensitiveMatch:o,debug:u,dot:g,followSymbolicLinks:f,onlyDirectories:y}=t,h=r.root.replace(V,""),m={dot:g,nobrace:t.braceExpansion===!1,nocase:!o,noextglob:t.extglob===!1,noglobstar:t.globstar===!1,posix:!0},l=n.unignore.length>0,p=l?$(n.unignore,m):void 0,a=l?L(n.unignore,m):void 0,c=$(n.match,{...m,ignore:n.ignore,onIgnore:p?v=>p(v.output)&&$.constants.UNIGNORE:void 0}),_=$(n.ignore,m),d=L(n.match,m),k=I(s,h,i),E=i?k:I(s,h,!0),nt=n.match.length>0&&n.match.every(v=>v==="**"||v==="**/*"),q=n.ignore.length>0||l||!nt?(v,w)=>{const b=E(w,!0);return b==="."||a&&a(b)?!1:!d(b)||_(b)}:void 0;let W;t.deep!==void 0&&(W=Math.round(t.deep-r.depthOffset));const ot=new ge({filters:[u?(v,w)=>{const b=k(v,w),B=c(b);return B&&x(`matched ${b}`),B}:(v,w)=>{const b=k(v,w);return c(b)}],exclude:u&&q?(v,w)=>{const b=q(v,w);return x(`${b?"skipped":"crawling"} ${w}`),b}:q,fs:t.fs,pathSeparator:"/",relativePaths:!i,resolvePaths:i,includeBasePath:i,resolveSymlinks:f,excludeSymlinks:!f,excludeFiles:y,includeDirs:y||!t.onlyFiles,maxDepth:W,signal:t.signal}).crawl(h);return t.debug&&x("internal properties:",{...r,root:h}),[ot,s!==h&&!i&&we(s,h)]}function st(t,e){if(e)for(let s=t.length-1;s>=0;s--)t[s]=e(t[s]);return t}const z={caseSensitiveMatch:!0,debug:!!process.env.TINYGLOBBY_DEBUG,expandDirectories:!0,followSymbolicLinks:!0,onlyFiles:!0};function Oe(t){const e=Object.assign({},t);for(const s in z)e[s]===void 0&&Object.assign(e,{[s]:z[s]});return e.cwd=(e.cwd instanceof URL?vt(e.cwd):N(e.cwd||process.cwd())).replace(V,"/"),e.ignore=et(e.ignore),e.fs&&(e.fs={readdir:e.fs.readdir||gt,readdirSync:e.fs.readdirSync||ft,realpath:e.fs.realpath||pt,realpathSync:e.fs.realpathSync||ht,stat:e.fs.stat||at,statSync:e.fs.statSync||ct}),e.debug&&x("globbing with options:",e),e}function rt(t,e={}){var s;if(t&&e?.patterns)throw new Error("Cannot pass patterns as both an argument and an option");const r=de(t)||typeof t=="string",n=et((s=r?t:t.patterns)!==null&&s!==void 0?s:"**/*"),i=Oe(r?e:t);return n.length>0?je(i,n):[]}async function Re(t,e){const[s,r]=rt(t,e);return s?st(await s.withPromise(),r):[]}function Ce(t,e){const[s,r]=rt(t,e);return s?st(s.sync(),r):[]}export{Ce as E,Re as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as t}from"node:module";import{toPath as a}from"@visulima/path/utils";import{F_OK as u}from"./FIND_UP_STOP-CAwY1qU7.js";import f from"./assertValidFileOrDirectoryPath-BTlt945W.js";const n=t(import.meta.url),s=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,i=e=>{if(typeof s<"u"&&s.versions&&s.versions.node){const[o,r]=s.versions.node.split(".").map(Number);if(o>22||o===22&&r>=3||o===20&&r>=16)return s.getBuiltinModule(e)}return n(e)},{access:c}=i("node:fs/promises");async function d(e,o=u){f(e),e=a(e);try{return await c(e,o),!0}catch{return!1}}export{d as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as s}from"node:module";import{toPath as u}from"@visulima/path/utils";import{F_OK as f}from"./FIND_UP_STOP-CAwY1qU7.js";import a from"./assertValidFileOrDirectoryPath-BTlt945W.js";const n=s(import.meta.url),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,i=e=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[o,t]=r.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return r.getBuiltinModule(e)}return n(e)},{accessSync:c}=i("node:fs");function d(e,o=f){a(e),e=u(e);try{return c(e,o),!0}catch{return!1}}export{d as default};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Custom error class for handling JSON parsing or related errors.
|
|
3
|
-
* It can optionally include a file name and a code frame for better debugging.
|
|
4
|
-
* @example
|
|
5
|
-
* ```javascript
|
|
6
|
-
* import { JSONError } from "@visulima/fs/error";
|
|
7
|
-
* import { readJsonSync } from "@visulima/fs"; // Or any function that might throw this
|
|
8
|
-
* import { join } from "node:path";
|
|
9
|
-
*
|
|
10
|
-
* try {
|
|
11
|
-
* // Imagine readJsonSync encounters a malformed JSON file and throws JSONError
|
|
12
|
-
* // Forcing the scenario for demonstration:
|
|
13
|
-
* const simulateJsonError = (filePath, content) => {
|
|
14
|
-
* const err = new JSONError(`Unexpected token '}' at position 15`);
|
|
15
|
-
* err.fileName = filePath;
|
|
16
|
-
* // A real implementation might generate a code frame using a library
|
|
17
|
-
* err.codeFrame = ` 13 | "key": "value",
|
|
18
|
-
* > 14 | "anotherKey": "anotherValue",}
|
|
19
|
-
* | ^
|
|
20
|
-
* 15 | "lastKey": "end"
|
|
21
|
-
* `;
|
|
22
|
-
* throw err;
|
|
23
|
-
* };
|
|
24
|
-
*
|
|
25
|
-
* simulateJsonError(join("path", "to", "corrupted.json"), '{ "key": "value", "anotherKey": "anotherValue",} ');
|
|
26
|
-
* // const jsonData = readJsonSync(join("path", "to", "corrupted.json"));
|
|
27
|
-
* } catch (error) {
|
|
28
|
-
* if (error instanceof JSONError) {
|
|
29
|
-
* console.error(`JSON Error: ${error.message}`);
|
|
30
|
-
* // message property will include fileName and codeFrame if they were set.
|
|
31
|
-
* // console.error(`File: ${error.fileName}`);
|
|
32
|
-
* // console.error(`Code Frame:\n${error.codeFrame}`);
|
|
33
|
-
* } else {
|
|
34
|
-
* console.error("An unexpected error occurred:", error);
|
|
35
|
-
* }
|
|
36
|
-
* }
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
declare class JSONError extends Error {
|
|
40
|
-
#private;
|
|
41
|
-
fileName: string | undefined;
|
|
42
|
-
codeFrame: string | undefined;
|
|
43
|
-
override readonly name = "JSONError";
|
|
44
|
-
/**
|
|
45
|
-
* Creates a new JSONError instance.
|
|
46
|
-
* @param message The primary error message.
|
|
47
|
-
*/
|
|
48
|
-
constructor(message: string);
|
|
49
|
-
override get message(): string;
|
|
50
|
-
override set message(message: string);
|
|
51
|
-
}
|
|
52
|
-
export { JSONError as J };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as p}from"node:module";import{toPath as d}from"@visulima/path/utils";import{dirname as c,resolve as s}from"@visulima/path";import E from"./isAccessible-PmWJhV6I.js";import k from"./isAccessibleSync-BrbOtwdr.js";const v=p(import.meta.url),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,u=t=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[e,r]=i.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return i.getBuiltinModule(t)}return v(t)},{cwd:a}=i,{mkdir:h,rename:_,copyFile:S,unlink:D}=u("node:fs/promises"),{mkdirSync:$,renameSync:g,copyFileSync:b,unlinkSync:j}=u("node:fs");class T extends Error{constructor(e,r){super(`Source directory "${c(e)}" does not match destination directory "${c(r)}"`),this.name="SameDirectoryError"}}const l=(t,e)=>{if(!t||!e)throw new Error("Source and destination paths must not be empty");if(c(t)!==c(e))throw new T(t,e)},y=async(t,e,{cwd:r,directoryMode:o,overwrite:w,validateDirectory:m})=>{if(r&&(t=s(r,t),e=s(r,e)),m&&l(t,e),!w&&await E(e))throw new Error(`The destination file exists: ${e}`);await h(c(e),{mode:o,recursive:!0});try{await _(t,e)}catch(n){if(n.code==="EXDEV")await S(t,e),await D(t);else throw n}},f=(t,e,{cwd:r,directoryMode:o,overwrite:w,validateDirectory:m})=>{if(r&&(t=s(r,t),e=s(r,e)),m&&l(t,e),!w&&k(e))throw new Error(`The destination file exists: ${e}`);$(c(e),{mode:o,recursive:!0});try{g(t,e)}catch(n){if(n.code==="EXDEV")b(t,e),j(t);else throw n}},P=async(t,e,r={})=>{const o={overwrite:!0,validateDirectory:!1,...r,cwd:r.cwd?d(r.cwd):a()};await y(t,e,o)},R=(t,e,r)=>{const o={overwrite:!0,validateDirectory:!1,...r};o.cwd=o.cwd?d(o.cwd):a(),f(t,e,o)},V=async(t,e,r)=>{const o={overwrite:!0,...r,validateDirectory:!0};o.cwd=o.cwd?d(o.cwd):a(),await y(t,e,o)},X=(t,e,r)=>{const o={overwrite:!0,...r,validateDirectory:!0};o.cwd=o.cwd?d(o.cwd):a(),f(t,e,o)};export{P as move,R as moveSync,V as rename,X as renameSync};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as m}from"node:module";import{toPath as h}from"@visulima/path/utils";import j from"./assertValidFileOrDirectoryPath-BTlt945W.js";import{i as y}from"./map-read-error-CR3rQUxx.js";const d=m(import.meta.url),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,l=o=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[e,t]=r.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return r.getBuiltinModule(o)}return d(o)},{readFile:g}=l("node:fs/promises"),{unzip:_,brotliDecompress:b}=l("node:zlib"),w={brotli:b,gzip:_,none:(o,e)=>{e(null,o)}},T=async(o,e)=>{j(o),o=h(o);const{buffer:t,compression:f,encoding:p,flag:s}=e??{};let i;try{i=await g(o,s?{flag:s}:{})}catch(n){throw y(n,o)}return await new Promise((n,u)=>{w[f??"none"](i,(c,a)=>{c?u(c):n(t?a:a.toString(p??"utf8"))})})};export{T as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createRequire as a}from"node:module";import{toPath as b}from"@visulima/path/utils";import y from"./assertValidFileOrDirectoryPath-BTlt945W.js";import{i as h}from"./map-read-error-CR3rQUxx.js";const d=a(import.meta.url),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,c=o=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[e,t]=r.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return r.getBuiltinModule(o)}return d(o)},{readFileSync:m}=c("node:fs"),{unzipSync:g,brotliDecompressSync:_}=c("node:zlib"),j={brotli:_,gzip:g,none:o=>o},T=(o,e)=>{y(o),o=b(o);const{buffer:t,compression:f,encoding:l,flag:n}=e??{};let s;try{s=m(o,n?{flag:n}:{})}catch(u){throw h(u,o)}const p=j[f??"none"],i=p(s);return t?i:i.toString(l??"utf8")};export{T as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{parse as c}from"ini";import n from"./readFileSync-_fDF6Oj1.js";const f=(r,t)=>{const{bracketedArray:e=!0,...o}=t??{},a=n(r,{encoding:"utf8",...o});return c(a,{bracketedArray:e})};export{f as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{parse as a}from"smol-toml";import n from"./readFile-BswaBgM0.js";const c=async(r,t)=>{const o=await n(r,{encoding:"utf8",...t});return a(o)};export{c as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{parse as n}from"smol-toml";import e from"./readFileSync-_fDF6Oj1.js";const m=(o,r)=>{const t=e(o,{encoding:"utf8",...r});return n(t)};export{m as default};
|