@visulima/fs 5.0.0-alpha.2 → 5.0.0-alpha.21
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 +263 -0
- package/LICENSE.md +208 -131
- package/dist/eol.d.ts +31 -30
- package/dist/eol.js +3 -26
- package/dist/error.d.ts +273 -7
- package/dist/error.js +1 -7
- package/dist/glob-parent.d.ts +35 -0
- package/dist/glob-parent.js +1 -0
- package/dist/glob.d.ts +4 -0
- package/dist/glob.js +1 -0
- package/dist/index.d.ts +858 -36
- package/dist/index.js +1 -33
- package/dist/ini.d.ts +70 -0
- package/dist/ini.js +1 -0
- package/dist/is-glob.d.ts +34 -0
- package/dist/is-glob.js +1 -0
- package/dist/json5.d.ts +36 -0
- package/dist/json5.js +1 -0
- package/dist/jsonc.d.ts +65 -0
- package/dist/jsonc.js +1 -0
- package/dist/match.d.ts +46 -0
- package/dist/match.js +1 -0
- package/dist/packem_shared/AlreadyExistsError-CEu6_Tjb.js +1 -0
- package/dist/packem_shared/DirectoryError-ddlbUV8C.js +1 -0
- package/dist/packem_shared/F_OK-CAwY1qU7.js +1 -0
- package/dist/packem_shared/JSONError-D7h6PNWc.js +4 -0
- package/dist/packem_shared/NotEmptyError-DMh1o7UL.js +1 -0
- package/dist/packem_shared/NotFoundError-BPiW0icm.js +1 -0
- package/dist/packem_shared/PermissionError-B1Emi5a9.js +1 -0
- package/dist/packem_shared/WalkError-Olmh4908.js +1 -0
- package/dist/packem_shared/_commonjsHelpers-D6W6KoPK.js +1 -0
- package/dist/packem_shared/assertValidFileContents-BZFnXa7K.js +1 -0
- package/dist/packem_shared/assertValidFileOrDirectoryPath-DgPIPmZT.js +1 -0
- package/dist/packem_shared/build-rm-options-C1R4reBu.js +1 -0
- package/dist/packem_shared/collect-2KPTpCdX.js +1 -0
- package/dist/packem_shared/collectSync-BX55r_BH.js +1 -0
- package/dist/packem_shared/emptyDir-8utO028L.js +1 -0
- package/dist/packem_shared/emptyDirSync-Bk5fUX73.js +1 -0
- package/dist/packem_shared/ensureDir-CZ4oUFuo.js +1 -0
- package/dist/packem_shared/ensureDirSync-CoPWhbjM.js +1 -0
- package/dist/packem_shared/ensureFile-CF1cAAyh.js +1 -0
- package/dist/packem_shared/ensureFileSync-C3qR6naU.js +1 -0
- package/dist/packem_shared/ensureLink-LLLxlGHn.js +1 -0
- package/dist/packem_shared/ensureLinkSync-Dh_GtT8F.js +1 -0
- package/dist/packem_shared/ensureSymlink-D50kj2zl.js +1 -0
- package/dist/packem_shared/ensureSymlinkSync-BbVDPvI4.js +1 -0
- package/dist/packem_shared/findUp-BT07y_Me.js +1 -0
- package/dist/packem_shared/findUpSync-BvZiYsKJ.js +1 -0
- package/dist/packem_shared/get-file-info-type-CaWGXRjY.js +1 -0
- package/dist/packem_shared/glob-MHJQjR39.js +1 -0
- package/dist/packem_shared/glob-sync.d-ODRbh6wE.d.ts +54 -0
- package/dist/packem_shared/globSync-CwzlELgS.js +1 -0
- package/dist/packem_shared/index-CYIVJA0W.js +1 -0
- package/dist/packem_shared/index-DrapuBsB.js +1 -0
- package/dist/packem_shared/index-K-NNTkpb.js +11 -0
- package/dist/packem_shared/index-yGx8uzZs.js +1 -0
- package/dist/packem_shared/indexToLineColumn-BRSZFC6I-BKj3uzZt.js +6 -0
- package/dist/packem_shared/ini-preserve-CXc_xkpG.js +4 -0
- package/dist/packem_shared/is-stats-identical-CohsLtWy.js +1 -0
- package/dist/packem_shared/isAccessible-CDFxsAAo.js +1 -0
- package/dist/packem_shared/isAccessibleSync-5nzZWgin.js +1 -0
- package/dist/packem_shared/isFsCaseSensitive-CMZVY1A2.js +1 -0
- package/dist/packem_shared/json-error.d-DVILOyHc.d.ts +52 -0
- package/dist/packem_shared/jsonc-merge-CQMjx3Vw.js +2 -0
- package/dist/packem_shared/move-LmP6P9sn.js +1 -0
- package/dist/packem_shared/parseJson-Xx6vHYbv.js +1 -0
- package/dist/packem_shared/readFile-BAVMZg5e.js +1 -0
- package/dist/packem_shared/readFileSync-CGmzMUF2.js +1 -0
- package/dist/packem_shared/readIni-Cfl6HmTS.js +1 -0
- package/dist/packem_shared/readIniSync-DPg4UD0P.js +1 -0
- package/dist/packem_shared/readJson-kPx68Wv1.js +1 -0
- package/dist/packem_shared/readJson5-pXTL9nUE.js +1 -0
- package/dist/packem_shared/readJson5Sync-BedQc292.js +1 -0
- package/dist/packem_shared/readJsonSync-_HXNI3Se.js +1 -0
- package/dist/packem_shared/readJsonc-BzvuAXbT.js +1 -0
- package/dist/packem_shared/readJsoncSync-CVG1_QnX.js +1 -0
- package/dist/packem_shared/readToml-BO5CZK2P.js +1 -0
- package/dist/packem_shared/readTomlSync-1fKo0R52.js +1 -0
- package/dist/packem_shared/readYaml-DjK_Vqj1.js +1 -0
- package/dist/packem_shared/readYamlSync-C3h6KA2c.js +1 -0
- package/dist/packem_shared/remove-DH41Ov_c.js +1 -0
- package/dist/packem_shared/removeSync-50OEdnHd.js +1 -0
- package/dist/packem_shared/resolve-symlink-target-BofZSDIc.js +1 -0
- package/dist/packem_shared/sanitize-CU1xmyrg.js +1 -0
- package/dist/packem_shared/stripJsonComments-CzNR77MF.js +1 -0
- package/dist/packem_shared/to-uint-8-array-DwgaTasY.js +1 -0
- package/dist/packem_shared/types.d-CHp56oCv.d.ts +1660 -0
- package/dist/packem_shared/walk-D01Qmmvz.js +1 -0
- package/dist/packem_shared/walk-include-DCiVAwMP.js +1 -0
- package/dist/packem_shared/walkSync-BknSdmKD.js +1 -0
- package/dist/packem_shared/writeFile-DNGaDOMX.js +1 -0
- package/dist/packem_shared/writeFileSync-CE1i-eMA.js +1 -0
- package/dist/packem_shared/writeIni-DG7U4ji0.js +4 -0
- package/dist/packem_shared/writeIniSync-Ldt6HFLb.js +4 -0
- package/dist/packem_shared/writeJson-BkGlq1Kv.js +4 -0
- package/dist/packem_shared/writeJson5-Btud4sQh.js +4 -0
- package/dist/packem_shared/writeJson5Sync-Iln3i1IV.js +4 -0
- package/dist/packem_shared/writeJsonSync-HndmyvEK.js +4 -0
- package/dist/packem_shared/writeJsonc-9oiamG16.js +4 -0
- package/dist/packem_shared/writeJsoncSync-BHBziPiK.js +4 -0
- package/dist/packem_shared/writeToml-Cj57wZ8B.js +1 -0
- package/dist/packem_shared/writeTomlSync-B34ZZp0e.js +1 -0
- package/dist/packem_shared/writeYaml-BhQX2yN9.js +1 -0
- package/dist/packem_shared/writeYamlSync-DG01FBeC.js +1 -0
- package/dist/size.d.ts +246 -246
- package/dist/size.js +1 -144
- package/dist/toml.d.ts +63 -0
- package/dist/toml.js +1 -0
- package/dist/utils.d.ts +103 -6
- package/dist/utils.js +1 -6
- package/dist/yaml.d.ts +13 -5
- package/dist/yaml.js +1 -4
- package/package.json +89 -36
- package/dist/constants.d.ts +0 -42
- package/dist/ensure/ensure-dir-sync.d.ts +0 -14
- package/dist/ensure/ensure-dir.d.ts +0 -14
- package/dist/ensure/ensure-file-sync.d.ts +0 -15
- package/dist/ensure/ensure-file.d.ts +0 -27
- package/dist/ensure/ensure-link-sync.d.ts +0 -16
- package/dist/ensure/ensure-link.d.ts +0 -16
- package/dist/ensure/ensure-symlink-sync.d.ts +0 -23
- package/dist/ensure/ensure-symlink.d.ts +0 -23
- package/dist/ensure/utils/get-file-info-type.d.ts +0 -7
- package/dist/ensure/utils/is-stats-identical.d.ts +0 -3
- package/dist/ensure/utils/resolve-symlink-target.d.ts +0 -2
- package/dist/error/already-exists-error.d.ts +0 -39
- package/dist/error/directory-error.d.ts +0 -47
- package/dist/error/json-error.d.ts +0 -52
- package/dist/error/not-empty-error.d.ts +0 -51
- package/dist/error/not-found-error.d.ts +0 -44
- package/dist/error/permission-error.d.ts +0 -45
- package/dist/error/walk-error.d.ts +0 -51
- package/dist/find/collect-sync.d.ts +0 -31
- package/dist/find/collect.d.ts +0 -35
- package/dist/find/find-up-sync.d.ts +0 -42
- package/dist/find/find-up.d.ts +0 -46
- package/dist/find/utils/glob-to-regexp.d.ts +0 -2
- package/dist/find/utils/walk-include.d.ts +0 -2
- package/dist/find/walk-sync.d.ts +0 -34
- package/dist/find/walk.d.ts +0 -37
- package/dist/is-accessible-sync.d.ts +0 -3
- package/dist/is-accessible.d.ts +0 -29
- package/dist/move/index.d.ts +0 -68
- package/dist/move/types.d.ts +0 -36
- package/dist/move/utils/internal-move-file-sync.d.ts +0 -3
- package/dist/move/utils/internal-move-file.d.ts +0 -3
- package/dist/move/utils/validate-same-directory.d.ts +0 -2
- package/dist/packem_shared/AlreadyExistsError-6Y9hjgMn.js +0 -27
- package/dist/packem_shared/DirectoryError-BfYPkIYP.js +0 -27
- package/dist/packem_shared/F_OK-MldBaGxb.js +0 -8
- package/dist/packem_shared/JSONError-BkHRnInH.js +0 -26
- package/dist/packem_shared/NotEmptyError-B21RUlVr.js +0 -27
- package/dist/packem_shared/NotFoundError-BIp61X6k.js +0 -27
- package/dist/packem_shared/PermissionError-CjoiJgip.js +0 -27
- package/dist/packem_shared/WalkError-DUdQd6FT.js +0 -24
- package/dist/packem_shared/assertValidFileContents-BmcLtsGd.js +0 -7
- package/dist/packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js +0 -7
- package/dist/packem_shared/collect-DcBwsYYd.js +0 -14
- package/dist/packem_shared/collectSync-Bkjf9Dbm.js +0 -14
- package/dist/packem_shared/emptyDir-CYB5Tict.js +0 -43
- package/dist/packem_shared/emptyDirSync-BD8-1Ytl.js +0 -41
- package/dist/packem_shared/ensureDir-C_kuQ5Ik.js +0 -53
- package/dist/packem_shared/ensureDirSync-CI5g-uBI.js +0 -53
- package/dist/packem_shared/ensureFile-BUtXGlGT.js +0 -47
- package/dist/packem_shared/ensureFileSync-C8hASR-1.js +0 -47
- package/dist/packem_shared/ensureLink-BPnAG5-P.js +0 -54
- package/dist/packem_shared/ensureLinkSync-B-Z7X0ub.js +0 -54
- package/dist/packem_shared/ensureSymlink-U5B6J0BN.js +0 -73
- package/dist/packem_shared/ensureSymlinkSync-DHnZj-9F.js +0 -74
- package/dist/packem_shared/findUp-BSnyGqer.js +0 -85
- package/dist/packem_shared/findUpSync-jRHbSCMV.js +0 -85
- package/dist/packem_shared/get-file-info-type-FD4-jsyg.js +0 -14
- package/dist/packem_shared/index-CHM-in-V.js +0 -100
- package/dist/packem_shared/is-stats-identical-D8FxpvQU.js +0 -3
- package/dist/packem_shared/isAccessible-DuVrTNFV.js +0 -38
- package/dist/packem_shared/isAccessibleSync-DI8mM0fA.js +0 -38
- package/dist/packem_shared/isFsCaseSensitive-D-ayleCy.js +0 -62
- package/dist/packem_shared/move-DbpW5_vA.js +0 -134
- package/dist/packem_shared/parseJson-C8xb-3LR.js +0 -231
- package/dist/packem_shared/readFile-Iz7kvCCk.js +0 -65
- package/dist/packem_shared/readFileSync-6GEIrOnl.js +0 -53
- package/dist/packem_shared/readJson-vddQ97Ll.js +0 -22
- package/dist/packem_shared/readJsonSync-DzeAdYZl.js +0 -22
- package/dist/packem_shared/readYaml-D5q2a0e1.js +0 -10
- package/dist/packem_shared/readYamlSync-DMV4U-gi.js +0 -10
- package/dist/packem_shared/remove-_oDY3uKo.js +0 -38
- package/dist/packem_shared/removeSync-DETRj7Qn.js +0 -38
- package/dist/packem_shared/resolve-symlink-target-Kh4GovFf.js +0 -16
- package/dist/packem_shared/sanitize-lOzE6k2A.js +0 -205
- package/dist/packem_shared/stripJsonComments-vo4k0mpF.js +0 -19
- package/dist/packem_shared/to-uint-8-array-Dz2nF1y1.js +0 -19
- package/dist/packem_shared/walk-BhTbpr3y.js +0 -115
- package/dist/packem_shared/walk-include-CZco7BvN.js +0 -16
- package/dist/packem_shared/walkSync-DDBq95s8.js +0 -114
- package/dist/packem_shared/writeFile-DSHERs0Z.js +0 -83
- package/dist/packem_shared/writeFileSync-CJp1kXQR.js +0 -83
- package/dist/packem_shared/writeJson-C0OfLDbe.js +0 -50
- package/dist/packem_shared/writeJsonSync-Cs21FE7v.js +0 -50
- package/dist/packem_shared/writeYaml-n4xzYN9a.js +0 -24
- package/dist/packem_shared/writeYamlSync-DnOEnP10.js +0 -24
- package/dist/read/read-file-sync.d.ts +0 -37
- package/dist/read/read-file.d.ts +0 -41
- package/dist/read/read-json-sync.d.ts +0 -5
- package/dist/read/read-json.d.ts +0 -5
- package/dist/read/read-yaml-sync.d.ts +0 -4
- package/dist/read/read-yaml.d.ts +0 -4
- package/dist/remove/empty-dir-sync.d.ts +0 -23
- package/dist/remove/empty-dir.d.ts +0 -28
- package/dist/remove/remove-sync.d.ts +0 -27
- package/dist/remove/remove.d.ts +0 -32
- package/dist/sanitize.d.ts +0 -31
- package/dist/types.d.ts +0 -304
- package/dist/utils/assert-valid-file-contents.d.ts +0 -27
- package/dist/utils/assert-valid-file-or-directory-path.d.ts +0 -26
- package/dist/utils/parse-json.d.ts +0 -5
- package/dist/utils/strip-json-comments.d.ts +0 -44
- package/dist/write/utils/to-uint-8-array.d.ts +0 -2
- package/dist/write/write-file-sync.d.ts +0 -30
- package/dist/write/write-file.d.ts +0 -30
- package/dist/write/write-json-sync.d.ts +0 -29
- package/dist/write/write-json.d.ts +0 -30
- package/dist/write/write-yaml-sync.d.ts +0 -4
- package/dist/write/write-yaml.d.ts +0 -4
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
-
|
|
7
|
-
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
-
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
-
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
-
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
-
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
-
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
-
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
// Fallback to createRequire
|
|
17
|
-
return __cjs_require(module);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
readFileSync: readFileSync$1
|
|
22
|
-
} = __cjs_getBuiltinModule("node:fs");
|
|
23
|
-
const {
|
|
24
|
-
unzipSync,
|
|
25
|
-
brotliDecompressSync
|
|
26
|
-
} = __cjs_getBuiltinModule("node:zlib");
|
|
27
|
-
import { toPath } from '@visulima/path/utils';
|
|
28
|
-
import { R_OK } from './F_OK-MldBaGxb.js';
|
|
29
|
-
import PermissionError from './PermissionError-CjoiJgip.js';
|
|
30
|
-
import isAccessibleSync from './isAccessibleSync-DI8mM0fA.js';
|
|
31
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
32
|
-
|
|
33
|
-
const decompressionMethods = {
|
|
34
|
-
brotli: brotliDecompressSync,
|
|
35
|
-
gzip: unzipSync,
|
|
36
|
-
none: (buffer) => buffer
|
|
37
|
-
};
|
|
38
|
-
const readFileSync = (path, options) => {
|
|
39
|
-
assertValidFileOrDirectoryPath(path);
|
|
40
|
-
path = toPath(path);
|
|
41
|
-
if (!isAccessibleSync(path)) {
|
|
42
|
-
throw new PermissionError(`unable to read the non-accessible file: ${path}`);
|
|
43
|
-
}
|
|
44
|
-
if (!isAccessibleSync(path, R_OK)) {
|
|
45
|
-
throw new PermissionError(`invalid access to read file at: ${path}`);
|
|
46
|
-
}
|
|
47
|
-
const { buffer, compression, encoding, flag } = options ?? {};
|
|
48
|
-
const content = readFileSync$1(path, flag ? { encoding, flag } : { encoding });
|
|
49
|
-
const decompressed = decompressionMethods[compression ?? "none"](content);
|
|
50
|
-
return buffer ? decompressed : decompressed.toString();
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export { readFileSync as default };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { toPath } from '@visulima/path/utils';
|
|
2
|
-
import parseJson from './parseJson-C8xb-3LR.js';
|
|
3
|
-
import readFile from './readFile-Iz7kvCCk.js';
|
|
4
|
-
|
|
5
|
-
async function readJson(path, reviver, options) {
|
|
6
|
-
if (typeof reviver === "object") {
|
|
7
|
-
options = reviver;
|
|
8
|
-
reviver = void 0;
|
|
9
|
-
}
|
|
10
|
-
const content = await readFile(path, {
|
|
11
|
-
buffer: true,
|
|
12
|
-
encoding: void 0
|
|
13
|
-
});
|
|
14
|
-
let data = new TextDecoder().decode(content);
|
|
15
|
-
const { beforeParse, color } = options ?? {};
|
|
16
|
-
if (typeof beforeParse === "function") {
|
|
17
|
-
data = beforeParse(data);
|
|
18
|
-
}
|
|
19
|
-
return parseJson(data, reviver, toPath(path), { color });
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { readJson as default };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { toPath } from '@visulima/path/utils';
|
|
2
|
-
import parseJson from './parseJson-C8xb-3LR.js';
|
|
3
|
-
import readFileSync from './readFileSync-6GEIrOnl.js';
|
|
4
|
-
|
|
5
|
-
function readJsonSync(path, reviver, options) {
|
|
6
|
-
if (typeof reviver === "object") {
|
|
7
|
-
options = reviver;
|
|
8
|
-
reviver = void 0;
|
|
9
|
-
}
|
|
10
|
-
const content = readFileSync(path, {
|
|
11
|
-
buffer: true,
|
|
12
|
-
encoding: void 0
|
|
13
|
-
});
|
|
14
|
-
let data = new TextDecoder().decode(content);
|
|
15
|
-
const { beforeParse, color } = options ?? {};
|
|
16
|
-
if (typeof beforeParse === "function") {
|
|
17
|
-
data = beforeParse(data);
|
|
18
|
-
}
|
|
19
|
-
return parseJson(data, reviver, toPath(path), { color });
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { readJsonSync as default };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { parse } from 'yaml';
|
|
2
|
-
import readFile from './readFile-Iz7kvCCk.js';
|
|
3
|
-
|
|
4
|
-
async function readYaml(path, reviver, options) {
|
|
5
|
-
const { buffer, compression, encoding = "utf8", flag, ...parseOptions } = options ?? {};
|
|
6
|
-
const content = await readFile(path, { buffer, compression, encoding, flag });
|
|
7
|
-
return typeof reviver === "function" ? parse(content, reviver, parseOptions) : parse(content, parseOptions);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { readYaml as default };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { parse } from 'yaml';
|
|
2
|
-
import readFileSync from './readFileSync-6GEIrOnl.js';
|
|
3
|
-
|
|
4
|
-
function readYamlSync(path, reviver, options) {
|
|
5
|
-
const { buffer, compression, encoding = "utf8", flag, ...parseOptions } = options ?? {};
|
|
6
|
-
const content = readFileSync(path, { buffer, compression, encoding, flag });
|
|
7
|
-
return typeof reviver === "function" ? parse(content, reviver, parseOptions) : parse(content, parseOptions);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { readYamlSync as default };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
-
|
|
7
|
-
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
-
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
-
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
-
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
-
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
-
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
-
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
// Fallback to createRequire
|
|
17
|
-
return __cjs_require(module);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
unlink,
|
|
22
|
-
rm
|
|
23
|
-
} = __cjs_getBuiltinModule("node:fs/promises");
|
|
24
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
25
|
-
|
|
26
|
-
const remove = async (path, options = {}) => {
|
|
27
|
-
assertValidFileOrDirectoryPath(path);
|
|
28
|
-
try {
|
|
29
|
-
await unlink(path);
|
|
30
|
-
} catch {
|
|
31
|
-
}
|
|
32
|
-
try {
|
|
33
|
-
await rm(path, { force: true, maxRetries: options?.maxRetries, recursive: true, retryDelay: options?.retryDelay });
|
|
34
|
-
} catch {
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export { remove as default };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
-
|
|
7
|
-
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
-
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
-
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
-
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
-
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
-
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
-
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
// Fallback to createRequire
|
|
17
|
-
return __cjs_require(module);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
unlinkSync,
|
|
22
|
-
rmSync
|
|
23
|
-
} = __cjs_getBuiltinModule("node:fs");
|
|
24
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
25
|
-
|
|
26
|
-
const removeSync = (path, options = {}) => {
|
|
27
|
-
assertValidFileOrDirectoryPath(path);
|
|
28
|
-
try {
|
|
29
|
-
unlinkSync(path);
|
|
30
|
-
} catch {
|
|
31
|
-
}
|
|
32
|
-
try {
|
|
33
|
-
rmSync(path, { force: true, maxRetries: options?.maxRetries, recursive: true, retryDelay: options?.retryDelay });
|
|
34
|
-
} catch {
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export { removeSync as default };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { resolve, dirname } from '@visulima/path';
|
|
2
|
-
|
|
3
|
-
const resolveSymlinkTarget = (target, linkName) => {
|
|
4
|
-
if (typeof target !== "string") {
|
|
5
|
-
return target;
|
|
6
|
-
}
|
|
7
|
-
if (target.startsWith("./")) {
|
|
8
|
-
return resolve(target);
|
|
9
|
-
}
|
|
10
|
-
if (typeof linkName === "string") {
|
|
11
|
-
return resolve(dirname(linkName), target);
|
|
12
|
-
}
|
|
13
|
-
return new URL(target, linkName);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { resolveSymlinkTarget as r };
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
platform
|
|
9
|
-
} = __cjs_getProcess;
|
|
10
|
-
|
|
11
|
-
const FALLBACK_NAME = "unnamed";
|
|
12
|
-
const MAX_LENGTH = 128;
|
|
13
|
-
const REPLACEMENT_CHARACTERS = {
|
|
14
|
-
'"': "ˮ",
|
|
15
|
-
// 0x02EE - MODIFIER LETTER DOUBLE APOSTROPHE
|
|
16
|
-
"*": "⁎",
|
|
17
|
-
// 0x204E - LOW ASTERISK
|
|
18
|
-
"/": "⁄",
|
|
19
|
-
// 0x2044 - FRACTION SLASH
|
|
20
|
-
":": "꞉",
|
|
21
|
-
// 0xA789 - MODIFIER LETTER COLON
|
|
22
|
-
"<": "‹",
|
|
23
|
-
// 0x2039 - SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
|
24
|
-
">": "›",
|
|
25
|
-
// 0x203A - SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
|
26
|
-
"?": "ʔ",
|
|
27
|
-
// 0x0294 - LATIN LETTER GLOTTAL STOP
|
|
28
|
-
"\\": "∖",
|
|
29
|
-
// 0x2216 - SET MINUS
|
|
30
|
-
"|": "ǀ"
|
|
31
|
-
// 0x01C0 - LATIN LETTER DENTAL CLICK
|
|
32
|
-
};
|
|
33
|
-
const CONTROL_CHARS_REGEX = /[\u0000-\u001F\u0080-\u009F]/g;
|
|
34
|
-
const RELATIVE_PATHS_REGEX = /^(?:\.+[/\\]+)+|^\.+$/g;
|
|
35
|
-
const WINDOWS_SPECIAL_NAMES_REGEX = /^(?:con|prn|aux|nul|com\d|lpt\d)$/i;
|
|
36
|
-
const WINDOWS_FORBIDDEN_CHARS_REGEX = /[<>:"/\\|?*]/g;
|
|
37
|
-
const UNIX_FORBIDDEN_CHARS_REGEX = /\//g;
|
|
38
|
-
const TRIM_CHARS = /* @__PURE__ */ new Set([" ", " ", "."]);
|
|
39
|
-
const hasExtension = (name, lastDotIndex) => lastDotIndex > 0 && lastDotIndex < name.length - 1;
|
|
40
|
-
const truncateWithExtension = (name, maxLength) => {
|
|
41
|
-
const lastDotIndex = name.lastIndexOf(".");
|
|
42
|
-
if (!hasExtension(name, lastDotIndex)) {
|
|
43
|
-
return name.slice(0, maxLength);
|
|
44
|
-
}
|
|
45
|
-
const baseName = name.slice(0, lastDotIndex);
|
|
46
|
-
const extension = name.slice(lastDotIndex);
|
|
47
|
-
const maxBaseLength = maxLength - extension.length;
|
|
48
|
-
return maxBaseLength > 0 ? `${baseName.slice(0, maxBaseLength)}${extension}` : name.slice(0, maxLength);
|
|
49
|
-
};
|
|
50
|
-
const trimSpacesAndPeriods = (input) => {
|
|
51
|
-
let start = 0;
|
|
52
|
-
let end = input.length;
|
|
53
|
-
while (start < end) {
|
|
54
|
-
const char = input[start];
|
|
55
|
-
if (char === void 0 || !TRIM_CHARS.has(char)) {
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
start += 1;
|
|
59
|
-
}
|
|
60
|
-
while (end > start) {
|
|
61
|
-
const char = input[end - 1];
|
|
62
|
-
if (char === void 0 || !TRIM_CHARS.has(char)) {
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
end -= 1;
|
|
66
|
-
}
|
|
67
|
-
return input.slice(start, end);
|
|
68
|
-
};
|
|
69
|
-
const cleanWindowsName = (name) => {
|
|
70
|
-
const lastDotIndex = name.lastIndexOf(".");
|
|
71
|
-
if (hasExtension(name, lastDotIndex)) {
|
|
72
|
-
const baseName = name.slice(0, lastDotIndex);
|
|
73
|
-
const extension = name.slice(lastDotIndex);
|
|
74
|
-
let cleanedBaseName = baseName;
|
|
75
|
-
while (cleanedBaseName.length > 0) {
|
|
76
|
-
const char = cleanedBaseName[cleanedBaseName.length - 1];
|
|
77
|
-
if (char === void 0 || !TRIM_CHARS.has(char)) {
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
cleanedBaseName = cleanedBaseName.slice(0, -1);
|
|
81
|
-
}
|
|
82
|
-
if (cleanedBaseName.length === 0) {
|
|
83
|
-
return extension.slice(1);
|
|
84
|
-
}
|
|
85
|
-
return `${cleanedBaseName}${extension}`;
|
|
86
|
-
}
|
|
87
|
-
let cleaned = name;
|
|
88
|
-
while (cleaned.length > 0) {
|
|
89
|
-
const char = cleaned[cleaned.length - 1];
|
|
90
|
-
if (char === void 0 || !TRIM_CHARS.has(char)) {
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
cleaned = cleaned.slice(0, -1);
|
|
94
|
-
}
|
|
95
|
-
return cleaned;
|
|
96
|
-
};
|
|
97
|
-
const isWindowsReservedName = (name) => {
|
|
98
|
-
const lastDotIndex = name.lastIndexOf(".");
|
|
99
|
-
if (hasExtension(name, lastDotIndex)) {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
if (WINDOWS_SPECIAL_NAMES_REGEX.test(name)) {
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
let trimmed = name;
|
|
106
|
-
while (trimmed.length > 0) {
|
|
107
|
-
const char = trimmed[trimmed.length - 1];
|
|
108
|
-
if (char === void 0 || !TRIM_CHARS.has(char)) {
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
trimmed = trimmed.slice(0, -1);
|
|
112
|
-
}
|
|
113
|
-
if (trimmed.length > 0 && WINDOWS_SPECIAL_NAMES_REGEX.test(trimmed)) {
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
return false;
|
|
117
|
-
};
|
|
118
|
-
const cleanFat32Name = (name) => {
|
|
119
|
-
const lastDotIndex = name.lastIndexOf(".");
|
|
120
|
-
if (hasExtension(name, lastDotIndex)) {
|
|
121
|
-
const baseName = name.slice(0, lastDotIndex);
|
|
122
|
-
const extension = name.slice(lastDotIndex);
|
|
123
|
-
const cleanedBaseName = trimSpacesAndPeriods(baseName);
|
|
124
|
-
if (cleanedBaseName.length === 0) {
|
|
125
|
-
return void 0;
|
|
126
|
-
}
|
|
127
|
-
return `${cleanedBaseName}${extension}`;
|
|
128
|
-
}
|
|
129
|
-
const trimmed = name.trim();
|
|
130
|
-
if (trimmed.length > 0 && trimmed[0] === "." && trimmed.length <= 5) {
|
|
131
|
-
const secondDotIndex = trimmed.indexOf(".", 1);
|
|
132
|
-
if (secondDotIndex === -1) {
|
|
133
|
-
return void 0;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
const cleaned = trimSpacesAndPeriods(name);
|
|
137
|
-
if (cleaned.length === 0) {
|
|
138
|
-
return void 0;
|
|
139
|
-
}
|
|
140
|
-
return cleaned;
|
|
141
|
-
};
|
|
142
|
-
const getFileSystemType = (options) => {
|
|
143
|
-
const filesystem = options?.filesystem ?? "auto";
|
|
144
|
-
if (filesystem === "auto") {
|
|
145
|
-
return platform === "win32" ? "win32" : "unix";
|
|
146
|
-
}
|
|
147
|
-
if (filesystem === "darwin") {
|
|
148
|
-
return "unix";
|
|
149
|
-
}
|
|
150
|
-
return filesystem;
|
|
151
|
-
};
|
|
152
|
-
const sanitize = (name, options) => {
|
|
153
|
-
if (typeof name !== "string" || name.length === 0) {
|
|
154
|
-
return FALLBACK_NAME;
|
|
155
|
-
}
|
|
156
|
-
const fileSystemType = getFileSystemType(options);
|
|
157
|
-
let sanitized = name;
|
|
158
|
-
sanitized = sanitized.replace(CONTROL_CHARS_REGEX, "");
|
|
159
|
-
if (sanitized.length === 0) {
|
|
160
|
-
return FALLBACK_NAME;
|
|
161
|
-
}
|
|
162
|
-
sanitized = sanitized.replace(RELATIVE_PATHS_REGEX, "");
|
|
163
|
-
if (sanitized.length === 0) {
|
|
164
|
-
return FALLBACK_NAME;
|
|
165
|
-
}
|
|
166
|
-
if (fileSystemType === "win32" || fileSystemType === "fat32") {
|
|
167
|
-
const lastDotIndex = sanitized.lastIndexOf(".");
|
|
168
|
-
if (!hasExtension(sanitized, lastDotIndex) && WINDOWS_SPECIAL_NAMES_REGEX.test(sanitized)) {
|
|
169
|
-
return FALLBACK_NAME;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
sanitized = fileSystemType === "win32" || fileSystemType === "fat32" ? sanitized.replaceAll(WINDOWS_FORBIDDEN_CHARS_REGEX, (char) => REPLACEMENT_CHARACTERS[char] ?? "") : sanitized.replaceAll(UNIX_FORBIDDEN_CHARS_REGEX, REPLACEMENT_CHARACTERS["/"]);
|
|
173
|
-
sanitized = sanitized.trim();
|
|
174
|
-
if (fileSystemType === "win32" || fileSystemType === "fat32") {
|
|
175
|
-
if (isWindowsReservedName(sanitized)) {
|
|
176
|
-
return FALLBACK_NAME;
|
|
177
|
-
}
|
|
178
|
-
if (fileSystemType === "win32") {
|
|
179
|
-
sanitized = cleanWindowsName(sanitized);
|
|
180
|
-
if (sanitized.length === 0) {
|
|
181
|
-
return FALLBACK_NAME;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (fileSystemType === "fat32") {
|
|
186
|
-
const cleaned = cleanFat32Name(sanitized);
|
|
187
|
-
if (cleaned === void 0) {
|
|
188
|
-
return FALLBACK_NAME;
|
|
189
|
-
}
|
|
190
|
-
sanitized = cleaned;
|
|
191
|
-
}
|
|
192
|
-
if (sanitized.length === 0) {
|
|
193
|
-
return FALLBACK_NAME;
|
|
194
|
-
}
|
|
195
|
-
const maxLength = options?.maxLength ?? MAX_LENGTH;
|
|
196
|
-
if (sanitized.length > maxLength) {
|
|
197
|
-
sanitized = truncateWithExtension(sanitized, maxLength);
|
|
198
|
-
if (sanitized.length === 0) {
|
|
199
|
-
return FALLBACK_NAME;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
return sanitized;
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
export { sanitize };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { INTERNAL_STRIP_JSON_REGEX } from './F_OK-MldBaGxb.js';
|
|
2
|
-
|
|
3
|
-
const stripJsonComments = (jsonString, { whitespace = true } = {}) => (
|
|
4
|
-
// This regular expression translates to:
|
|
5
|
-
//
|
|
6
|
-
// /quoted-string|line-comment|block-comment/g
|
|
7
|
-
//
|
|
8
|
-
// This means that comment characters inside of strings will match
|
|
9
|
-
// as strings, not comments, so we can just skip the whole string
|
|
10
|
-
// in the replacer function.
|
|
11
|
-
jsonString.replace(INTERNAL_STRIP_JSON_REGEX, (match) => {
|
|
12
|
-
if (match.startsWith('"') || match[1] === "*" && !match.endsWith("*/")) {
|
|
13
|
-
return match;
|
|
14
|
-
}
|
|
15
|
-
return whitespace ? match.replaceAll(/\S/g, " ") : "";
|
|
16
|
-
})
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
export { stripJsonComments as default };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const encoder = new TextEncoder();
|
|
2
|
-
const toUint8Array = (contents) => {
|
|
3
|
-
if (contents instanceof Uint8Array) {
|
|
4
|
-
return contents;
|
|
5
|
-
}
|
|
6
|
-
if (typeof contents === "string") {
|
|
7
|
-
return encoder.encode(contents);
|
|
8
|
-
}
|
|
9
|
-
if (contents instanceof ArrayBuffer) {
|
|
10
|
-
return new Uint8Array(contents);
|
|
11
|
-
}
|
|
12
|
-
if (ArrayBuffer.isView(contents)) {
|
|
13
|
-
const bytes = contents.buffer.slice(contents.byteOffset, contents.byteOffset + contents.byteLength);
|
|
14
|
-
return new Uint8Array(bytes);
|
|
15
|
-
}
|
|
16
|
-
throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.");
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export { toUint8Array as t };
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
-
|
|
7
|
-
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
-
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
-
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
-
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
-
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
-
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
-
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
// Fallback to createRequire
|
|
17
|
-
return __cjs_require(module);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
readdir,
|
|
22
|
-
realpath,
|
|
23
|
-
stat
|
|
24
|
-
} = __cjs_getBuiltinModule("node:fs/promises");
|
|
25
|
-
import { resolve, join, normalize, basename } from '@visulima/path';
|
|
26
|
-
import { toPath } from '@visulima/path/utils';
|
|
27
|
-
import WalkError from './WalkError-DUdQd6FT.js';
|
|
28
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
29
|
-
import { g as globToRegExp, w as walkInclude } from './walk-include-CZco7BvN.js';
|
|
30
|
-
|
|
31
|
-
const _createWalkEntry = async (path) => {
|
|
32
|
-
const normalizePath = normalize(path);
|
|
33
|
-
const name = basename(normalizePath);
|
|
34
|
-
const info = await stat(normalizePath);
|
|
35
|
-
return {
|
|
36
|
-
isDirectory: () => info.isDirectory(),
|
|
37
|
-
isFile: () => info.isFile(),
|
|
38
|
-
isSymbolicLink: () => info.isSymbolicLink(),
|
|
39
|
-
name,
|
|
40
|
-
path: normalizePath
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
async function* walk(directory, {
|
|
44
|
-
extensions,
|
|
45
|
-
followSymlinks = false,
|
|
46
|
-
includeDirs: includeDirectories = true,
|
|
47
|
-
includeFiles = true,
|
|
48
|
-
includeSymlinks = true,
|
|
49
|
-
match,
|
|
50
|
-
maxDepth = Number.POSITIVE_INFINITY,
|
|
51
|
-
skip
|
|
52
|
-
} = {}) {
|
|
53
|
-
assertValidFileOrDirectoryPath(directory);
|
|
54
|
-
if (maxDepth < 0) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const mappedMatch = match ? match.map((pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern) : void 0;
|
|
58
|
-
const mappedSkip = skip ? skip.map((pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern) : void 0;
|
|
59
|
-
directory = resolve(toPath(directory));
|
|
60
|
-
if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {
|
|
61
|
-
yield await _createWalkEntry(directory);
|
|
62
|
-
}
|
|
63
|
-
if (maxDepth < 1 || !walkInclude(directory, void 0, void 0, mappedSkip)) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
try {
|
|
67
|
-
for await (const entry of await readdir(directory, {
|
|
68
|
-
withFileTypes: true
|
|
69
|
-
})) {
|
|
70
|
-
let path = join(directory, entry.name);
|
|
71
|
-
if (entry.isSymbolicLink()) {
|
|
72
|
-
if (followSymlinks) {
|
|
73
|
-
path = await realpath(path);
|
|
74
|
-
} else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {
|
|
75
|
-
yield {
|
|
76
|
-
isDirectory: entry.isDirectory,
|
|
77
|
-
isFile: entry.isFile,
|
|
78
|
-
isSymbolicLink: entry.isSymbolicLink,
|
|
79
|
-
name: entry.name,
|
|
80
|
-
path
|
|
81
|
-
};
|
|
82
|
-
} else {
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (entry.isSymbolicLink() || entry.isDirectory()) {
|
|
87
|
-
yield* walk(path, {
|
|
88
|
-
extensions,
|
|
89
|
-
followSymlinks,
|
|
90
|
-
includeDirs: includeDirectories,
|
|
91
|
-
includeFiles,
|
|
92
|
-
includeSymlinks,
|
|
93
|
-
match: mappedMatch,
|
|
94
|
-
maxDepth: maxDepth - 1,
|
|
95
|
-
skip: mappedSkip
|
|
96
|
-
});
|
|
97
|
-
} else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {
|
|
98
|
-
yield {
|
|
99
|
-
isDirectory: () => entry.isDirectory(),
|
|
100
|
-
isFile: () => entry.isFile(),
|
|
101
|
-
isSymbolicLink: () => entry.isSymbolicLink(),
|
|
102
|
-
name: entry.name,
|
|
103
|
-
path
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
} catch (error) {
|
|
108
|
-
if (error instanceof WalkError) {
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
throw new WalkError(error, directory);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export { walk as default };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const globToRegExp = (glob) => {
|
|
2
|
-
const reString = glob.replace(/\.\*/g, ".([^/]*)").replace(/\*\*/g, "(.*)").replace(/(?<!\.)\*(?!\*)/g, "([^/]*)").replace(/\?/g, "[^/]").replace(/\.(?!\*)/g, String.raw`\.`).replace(/\{/g, "(").replace(/\}/g, ")").replace(/,/g, "|").replace(/\[!(.*?)\]/g, "[^$1]");
|
|
3
|
-
return new RegExp(`^${reString}$`);
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
const walkInclude = (path, extensions, match, skip) => {
|
|
7
|
-
if (Array.isArray(extensions) && extensions.length > 0 && !extensions.some((extension) => path.endsWith(extension))) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
if (match && !match.some((pattern) => pattern.test(path))) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
return !skip?.some((pattern) => pattern.test(path));
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { globToRegExp as g, walkInclude as w };
|