@visulima/fs 5.0.0-alpha.9 → 5.0.1
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 +461 -0
- package/LICENSE.md +81 -4
- package/README.md +65 -0
- package/dist/eol.d.ts +30 -0
- package/dist/eol.js +3 -26
- package/dist/error.d.ts +243 -13
- package/dist/error.js +1 -7
- package/dist/glob-parent.d.ts +30 -0
- package/dist/glob-parent.js +1 -90
- package/dist/glob.d.ts +3 -4
- package/dist/glob.js +1 -2
- package/dist/index.d.ts +877 -28
- package/dist/index.js +1 -38
- package/dist/ini.d.ts +64 -4
- package/dist/ini.js +1 -4
- package/dist/is-glob.d.ts +29 -0
- package/dist/is-glob.js +1 -9
- package/dist/json5.d.ts +28 -4
- package/dist/json5.js +1 -4
- package/dist/jsonc.d.ts +59 -4
- package/dist/jsonc.js +1 -4
- package/dist/match.d.ts +77 -2
- package/dist/match.js +1 -15
- package/dist/packem_shared/AlreadyExistsError-DEb3UWja.js +1 -0
- package/dist/packem_shared/DirectoryError-BtwSTLmT.js +1 -0
- package/dist/packem_shared/FIND_UP_STOP-CAwY1qU7.js +1 -0
- package/dist/packem_shared/JSONError-Cvp9ycba.js +4 -0
- package/dist/packem_shared/NotEmptyError-DZ1Ix089.js +1 -0
- package/dist/packem_shared/NotFoundError-CnRY6lVp.js +1 -0
- package/dist/packem_shared/PermissionError-DJ_2VWEj.js +1 -0
- package/dist/packem_shared/WalkError-B8qTd-v-.js +1 -0
- package/dist/packem_shared/_commonjsHelpers-CWAkuNXM.js +1 -0
- package/dist/packem_shared/assertValidFileContents-CbIN7sy7.js +1 -0
- package/dist/packem_shared/assertValidFileOrDirectoryPath-BTlt945W.js +1 -0
- package/dist/packem_shared/build-rm-options-avnusYx-.js +1 -0
- package/dist/packem_shared/collect-CIKDOMiD.js +1 -0
- package/dist/packem_shared/collectSync-D0FRLLqg.js +1 -0
- package/dist/packem_shared/copy-Beb64BYG.js +1 -0
- package/dist/packem_shared/copySync-CagcIEBi.js +1 -0
- package/dist/packem_shared/emptyDir-C7lyd1lW.js +1 -0
- package/dist/packem_shared/emptyDirSync-B8EYpmO9.js +1 -0
- package/dist/packem_shared/ensureDir-DGarVZw8.js +1 -0
- package/dist/packem_shared/ensureDirSync-CsgPrsDH.js +1 -0
- package/dist/packem_shared/ensureFile-CMugWljp.js +1 -0
- package/dist/packem_shared/ensureFileSync-CJYTEx2r.js +1 -0
- package/dist/packem_shared/ensureLink-ChShf3lf.js +1 -0
- package/dist/packem_shared/ensureLinkSync-DPpq0I2Z.js +1 -0
- package/dist/packem_shared/ensureSymlink-y4FZjfxA.js +1 -0
- package/dist/packem_shared/ensureSymlinkSync-TcHssCH7.js +1 -0
- package/dist/packem_shared/findUp-Cii5ATt5.js +1 -0
- package/dist/packem_shared/findUpSync-C9Lkh7-v.js +1 -0
- package/dist/packem_shared/get-file-info-type-DzWpohDB.js +1 -0
- package/dist/packem_shared/glob-DMbPwGSj.js +1 -0
- package/dist/packem_shared/glob-sync.d-hXe38TnZ.d.ts +54 -0
- package/dist/packem_shared/globSync-DiP2rtGn.js +1 -0
- package/dist/packem_shared/index-B2MhYg3r.js +1 -0
- package/dist/packem_shared/index-BHy3Kcr7.js +11 -0
- package/dist/packem_shared/index-Ct4GqZSP.js +1 -0
- package/dist/packem_shared/index-LUKYN3u3.js +1 -0
- package/dist/packem_shared/ini-preserve-D1DopDLd.js +4 -0
- package/dist/packem_shared/is-stats-identical-l1GRN4Qu.js +1 -0
- package/dist/packem_shared/isAccessible-PmWJhV6I.js +1 -0
- package/dist/packem_shared/isAccessibleSync-BrbOtwdr.js +1 -0
- package/dist/packem_shared/json-error.d-DVILOyHc.d.ts +52 -0
- package/dist/packem_shared/jsonc-merge-Bkw73TLW.js +2 -0
- package/dist/packem_shared/map-read-error-CR3rQUxx.js +1 -0
- package/dist/packem_shared/move-DopmzT-2.js +1 -0
- package/dist/packem_shared/parseJson-EASgP4J9.js +1 -0
- package/dist/packem_shared/readFile-BswaBgM0.js +1 -0
- package/dist/packem_shared/readFileSync-_fDF6Oj1.js +1 -0
- package/dist/packem_shared/readIni-BsXudu2r.js +1 -0
- package/dist/packem_shared/readIniSync-DKwRbbs9.js +1 -0
- package/dist/packem_shared/readJson-CcAsHxE5.js +1 -0
- package/dist/packem_shared/readJson5-CM1TIiHd.js +1 -0
- package/dist/packem_shared/readJson5Sync-Bc26c3Fy.js +1 -0
- package/dist/packem_shared/readJsonSync-DuMMeB3s.js +1 -0
- package/dist/packem_shared/readJsonc-BZjMw_0f.js +1 -0
- package/dist/packem_shared/readJsoncSync-C-xzeZz4.js +1 -0
- package/dist/packem_shared/readToml-D4jpe9q_.js +1 -0
- package/dist/packem_shared/readTomlSync-B5PIYT9z.js +1 -0
- package/dist/packem_shared/readYaml-DvPxndW_.js +1 -0
- package/dist/packem_shared/readYamlSync-DZ-0hSbZ.js +1 -0
- package/dist/packem_shared/remove-CSbrd0dl.js +1 -0
- package/dist/packem_shared/removeSync-BoLAzRQE.js +1 -0
- package/dist/packem_shared/renderError-B3ePOoBG-Bi9WKMjv.js +6 -0
- package/dist/packem_shared/resolve-symlink-target-CWrn0v4P.js +1 -0
- package/dist/packem_shared/sanitize-DGZ3w-_w.js +1 -0
- package/dist/packem_shared/stripJsonComments-Bfcn2PKv.js +1 -0
- package/dist/packem_shared/to-uint-8-array-BImOQNXm.js +1 -0
- package/dist/packem_shared/types.d-BMdL_ygj.d.ts +1773 -0
- package/dist/packem_shared/walk-OX4-6oCP.js +1 -0
- package/dist/packem_shared/walk-include-BXhGSn6t.js +1 -0
- package/dist/packem_shared/walkSync-BPs6czIM.js +1 -0
- package/dist/packem_shared/writeFile-BrMtsJY7.js +1 -0
- package/dist/packem_shared/writeFileSync-W7Mf4BNy.js +1 -0
- package/dist/packem_shared/writeIni-BWX3cP1K.js +4 -0
- package/dist/packem_shared/writeIniSync-fOdgPFfL.js +4 -0
- package/dist/packem_shared/writeJson-bEVi25gX.js +4 -0
- package/dist/packem_shared/writeJson5-Ch8TpNPI.js +4 -0
- package/dist/packem_shared/writeJson5Sync-BrctV_Mk.js +4 -0
- package/dist/packem_shared/writeJsonSync-DkGnd416.js +4 -0
- package/dist/packem_shared/writeJsonc-CefrwsOc.js +4 -0
- package/dist/packem_shared/writeJsoncSync-BskDjn8o.js +4 -0
- package/dist/packem_shared/writeToml-IuMO-yDu.js +1 -0
- package/dist/packem_shared/writeTomlSync-DhL7hHzB.js +1 -0
- package/dist/packem_shared/writeYaml-ClQgvQID.js +1 -0
- package/dist/packem_shared/writeYamlSync-DrXtHQQq.js +1 -0
- package/dist/size.d.ts +244 -0
- package/dist/size.js +1 -146
- package/dist/toml.d.ts +57 -3
- package/dist/toml.js +1 -4
- package/dist/utils.d.ts +92 -4
- package/dist/utils.js +1 -6
- package/dist/yaml.d.ts +3 -4
- package/dist/yaml.js +1 -4
- package/package.json +41 -44
- 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-DER5A43G.js +0 -24
- package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +0 -5
- package/dist/packem_shared/assertValidFileContents-BmcLtsGd.js +0 -7
- package/dist/packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js +0 -7
- package/dist/packem_shared/build-rm-options-Cl3VDY4O.js +0 -12
- package/dist/packem_shared/collect-CqQ3eVab.js +0 -14
- package/dist/packem_shared/collectSync-noE08NNv.js +0 -14
- package/dist/packem_shared/emptyDir-DnwENOaV.js +0 -46
- package/dist/packem_shared/emptyDirSync-6WiHBo8a.js +0 -43
- package/dist/packem_shared/ensureDir-DNlPftys.js +0 -53
- package/dist/packem_shared/ensureDirSync-DcPZFMy5.js +0 -53
- package/dist/packem_shared/ensureFile-BRQpUOUM.js +0 -47
- package/dist/packem_shared/ensureFileSync-SBY7A9-C.js +0 -47
- package/dist/packem_shared/ensureLink-DJQeauEn.js +0 -55
- package/dist/packem_shared/ensureLinkSync-D9RVAglV.js +0 -55
- package/dist/packem_shared/ensureSymlink-CoRYDRwr.js +0 -80
- package/dist/packem_shared/ensureSymlinkSync-CFimFlgh.js +0 -81
- package/dist/packem_shared/findUp-YcNLKdfV.js +0 -84
- package/dist/packem_shared/findUpSync-BfA5fheN.js +0 -83
- package/dist/packem_shared/get-file-info-type-FD4-jsyg.js +0 -14
- package/dist/packem_shared/glob-DY8l7izD.js +0 -5
- package/dist/packem_shared/glob-sync.d-B83kqwUd.d.ts +0 -4
- package/dist/packem_shared/globSync-5P2KJf_g.js +0 -5
- package/dist/packem_shared/index-C8W8sfzP.js +0 -830
- package/dist/packem_shared/index-CHM-in-V.js +0 -100
- package/dist/packem_shared/index-bhgnhm4u.js +0 -167
- package/dist/packem_shared/index-xe4o3cYi.js +0 -1784
- package/dist/packem_shared/indexToLineColumn-BUb0GPKl-BF770uX7.js +0 -171
- package/dist/packem_shared/ini-preserve-Dq_Q_Jgb.js +0 -251
- 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-DunL7Iry.js +0 -62
- package/dist/packem_shared/json-error.d-DgKaeuIf.d.ts +0 -10
- package/dist/packem_shared/jsonc-merge-C6jWcfWh.js +0 -72
- package/dist/packem_shared/move-DbpW5_vA.js +0 -134
- package/dist/packem_shared/parseJson-BIp89Xjo.js +0 -63
- package/dist/packem_shared/readFile-Iz7kvCCk.js +0 -65
- package/dist/packem_shared/readFileSync-gm9yfIhh.js +0 -54
- package/dist/packem_shared/readIni-CJ2xfpjB.js +0 -10
- package/dist/packem_shared/readIniSync-9LUjaSSp.js +0 -10
- package/dist/packem_shared/readJson-C_rwm-wq.js +0 -22
- package/dist/packem_shared/readJson5-mBoTZppy.js +0 -15
- package/dist/packem_shared/readJson5Sync-8WS2yUok.js +0 -15
- package/dist/packem_shared/readJsonSync-BMEmCcJ6.js +0 -22
- package/dist/packem_shared/readJsonc-j-OS-APg.js +0 -28
- package/dist/packem_shared/readJsoncSync-Aw6EMlWO.js +0 -16
- package/dist/packem_shared/readToml-B2MHaSes.js +0 -9
- package/dist/packem_shared/readTomlSync-DNbK8NEb.js +0 -9
- package/dist/packem_shared/readYaml-D5q2a0e1.js +0 -10
- package/dist/packem_shared/readYamlSync-BKX-PAfq.js +0 -10
- package/dist/packem_shared/remove-C8_gl3jF.js +0 -39
- package/dist/packem_shared/removeSync-BJR_wTwN.js +0 -39
- package/dist/packem_shared/resolve-symlink-target-Kh4GovFf.js +0 -16
- package/dist/packem_shared/sanitize-BZoLN9Fg.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/types.d-dP-lAGNn.d.ts +0 -145
- package/dist/packem_shared/walk-CSZgCuDx.js +0 -124
- package/dist/packem_shared/walk-include-CZco7BvN.js +0 -16
- package/dist/packem_shared/walkSync-C4Cy28xb.js +0 -123
- package/dist/packem_shared/writeFile-B8HX0JIQ.js +0 -81
- package/dist/packem_shared/writeFileSync-DB8vv8xR.js +0 -81
- package/dist/packem_shared/writeIni-i55QrL8y.js +0 -65
- package/dist/packem_shared/writeIniSync-CLqJE5t3.js +0 -64
- package/dist/packem_shared/writeJson-Bo7C2UHw.js +0 -50
- package/dist/packem_shared/writeJson5-vVmHUQOd.js +0 -53
- package/dist/packem_shared/writeJson5Sync-oJ546h5k.js +0 -53
- package/dist/packem_shared/writeJsonSync-BKZ_9Acr.js +0 -50
- package/dist/packem_shared/writeJsonc-BufH_oC5.js +0 -60
- package/dist/packem_shared/writeJsoncSync-DB9be1YL.js +0 -59
- package/dist/packem_shared/writeToml-DgTW_-7F.js +0 -8
- package/dist/packem_shared/writeTomlSync-DiBiE9ja.js +0 -8
- package/dist/packem_shared/writeYaml-BWCOome-.js +0 -24
- package/dist/packem_shared/writeYamlSync-DBVnXmuY.js +0 -24
|
@@ -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
|
-
lstat,
|
|
22
|
-
mkdir
|
|
23
|
-
} = __cjs_getBuiltinModule("node:fs/promises");
|
|
24
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
25
|
-
import { g as getFileInfoType } from './get-file-info-type-FD4-jsyg.js';
|
|
26
|
-
|
|
27
|
-
const ensureDir = async (directory) => {
|
|
28
|
-
assertValidFileOrDirectoryPath(directory);
|
|
29
|
-
try {
|
|
30
|
-
const fileInfo = await lstat(directory);
|
|
31
|
-
if (!fileInfo.isDirectory()) {
|
|
32
|
-
throw new Error(`Ensure path exists, expected 'dir', got '${String(getFileInfoType(fileInfo))}'`);
|
|
33
|
-
}
|
|
34
|
-
return;
|
|
35
|
-
} catch (error) {
|
|
36
|
-
if (error.code !== "ENOENT") {
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
await mkdir(directory, { recursive: true });
|
|
42
|
-
} catch (error) {
|
|
43
|
-
if (error.code !== "EEXIST") {
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
46
|
-
const fileInfo = await lstat(directory);
|
|
47
|
-
if (!fileInfo.isDirectory()) {
|
|
48
|
-
throw new Error(`Ensure path exists, expected 'dir', got '${String(getFileInfoType(fileInfo))}'`, { cause: error });
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export { ensureDir as default };
|
|
@@ -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
|
-
lstatSync,
|
|
22
|
-
mkdirSync
|
|
23
|
-
} = __cjs_getBuiltinModule("node:fs");
|
|
24
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
25
|
-
import { g as getFileInfoType } from './get-file-info-type-FD4-jsyg.js';
|
|
26
|
-
|
|
27
|
-
const ensureDirSync = (directory) => {
|
|
28
|
-
assertValidFileOrDirectoryPath(directory);
|
|
29
|
-
try {
|
|
30
|
-
const fileInfo = lstatSync(directory);
|
|
31
|
-
if (!fileInfo.isDirectory()) {
|
|
32
|
-
throw new Error(`Ensure path exists, expected 'dir', got '${String(getFileInfoType(fileInfo))}'`);
|
|
33
|
-
}
|
|
34
|
-
return;
|
|
35
|
-
} catch (error) {
|
|
36
|
-
if (error.code !== "ENOENT") {
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
mkdirSync(directory, { recursive: true });
|
|
42
|
-
} catch (error) {
|
|
43
|
-
if (error.code !== "EEXIST") {
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
46
|
-
const fileInfo = lstatSync(directory);
|
|
47
|
-
if (!fileInfo.isDirectory()) {
|
|
48
|
-
throw new Error(`Ensure path exists, expected 'dir', got '${String(getFileInfoType(fileInfo))}'`, { cause: error });
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export { ensureDirSync as default };
|
|
@@ -1,47 +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
|
-
lstat,
|
|
22
|
-
writeFile
|
|
23
|
-
} = __cjs_getBuiltinModule("node:fs/promises");
|
|
24
|
-
import { dirname } from '@visulima/path';
|
|
25
|
-
import { toPath } from '@visulima/path/utils';
|
|
26
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
27
|
-
import ensureDir from './ensureDir-DNlPftys.js';
|
|
28
|
-
import { g as getFileInfoType } from './get-file-info-type-FD4-jsyg.js';
|
|
29
|
-
|
|
30
|
-
const ensureFile = async (filePath) => {
|
|
31
|
-
assertValidFileOrDirectoryPath(filePath);
|
|
32
|
-
try {
|
|
33
|
-
const stat = await lstat(filePath);
|
|
34
|
-
if (!stat.isFile()) {
|
|
35
|
-
throw new Error(`Ensure path exists, expected 'file', got '${String(getFileInfoType(stat))}'`);
|
|
36
|
-
}
|
|
37
|
-
} catch (error) {
|
|
38
|
-
if (error.code === "ENOENT") {
|
|
39
|
-
await ensureDir(dirname(toPath(filePath)));
|
|
40
|
-
await writeFile(filePath, new Uint8Array());
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export { ensureFile as default };
|
|
@@ -1,47 +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
|
-
lstatSync,
|
|
22
|
-
writeFileSync
|
|
23
|
-
} = __cjs_getBuiltinModule("node:fs");
|
|
24
|
-
import { dirname } from '@visulima/path';
|
|
25
|
-
import { toPath } from '@visulima/path/utils';
|
|
26
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
27
|
-
import ensureDirSync from './ensureDirSync-DcPZFMy5.js';
|
|
28
|
-
import { g as getFileInfoType } from './get-file-info-type-FD4-jsyg.js';
|
|
29
|
-
|
|
30
|
-
const ensureFileSync = (filePath) => {
|
|
31
|
-
assertValidFileOrDirectoryPath(filePath);
|
|
32
|
-
try {
|
|
33
|
-
const stat = lstatSync(filePath);
|
|
34
|
-
if (!stat.isFile()) {
|
|
35
|
-
throw new Error(`Ensure path exists, expected 'file', got '${String(getFileInfoType(stat))}'`);
|
|
36
|
-
}
|
|
37
|
-
} catch (error) {
|
|
38
|
-
if (error.code === "ENOENT") {
|
|
39
|
-
ensureDirSync(dirname(toPath(filePath)));
|
|
40
|
-
writeFileSync(filePath, new Uint8Array());
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export { ensureFileSync as default };
|
|
@@ -1,55 +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
|
-
lstat,
|
|
22
|
-
link
|
|
23
|
-
} = __cjs_getBuiltinModule("node:fs/promises");
|
|
24
|
-
import { toNamespacedPath, dirname } from '@visulima/path';
|
|
25
|
-
import { toPath } from '@visulima/path/utils';
|
|
26
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
27
|
-
import ensureDir from './ensureDir-DNlPftys.js';
|
|
28
|
-
import { i as isStatsIdentical } from './is-stats-identical-D8FxpvQU.js';
|
|
29
|
-
|
|
30
|
-
const ensureLink = async (source, destination) => {
|
|
31
|
-
assertValidFileOrDirectoryPath(source);
|
|
32
|
-
assertValidFileOrDirectoryPath(destination);
|
|
33
|
-
source = toNamespacedPath(toPath(source));
|
|
34
|
-
destination = toNamespacedPath(toPath(destination));
|
|
35
|
-
let destinationStat;
|
|
36
|
-
try {
|
|
37
|
-
destinationStat = await lstat(destination);
|
|
38
|
-
} catch {
|
|
39
|
-
}
|
|
40
|
-
let sourceStat;
|
|
41
|
-
try {
|
|
42
|
-
sourceStat = await lstat(source);
|
|
43
|
-
} catch (error) {
|
|
44
|
-
const nodeError = error;
|
|
45
|
-
nodeError.message = nodeError.message.replace("lstat", "ensureLink");
|
|
46
|
-
throw nodeError;
|
|
47
|
-
}
|
|
48
|
-
if (destinationStat && isStatsIdentical(sourceStat, destinationStat)) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
await ensureDir(dirname(destination));
|
|
52
|
-
await link(source, destination);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export { ensureLink as default };
|
|
@@ -1,55 +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
|
-
lstatSync,
|
|
22
|
-
linkSync
|
|
23
|
-
} = __cjs_getBuiltinModule("node:fs");
|
|
24
|
-
import { toNamespacedPath, dirname } from '@visulima/path';
|
|
25
|
-
import { toPath } from '@visulima/path/utils';
|
|
26
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
27
|
-
import ensureDirSync from './ensureDirSync-DcPZFMy5.js';
|
|
28
|
-
import { i as isStatsIdentical } from './is-stats-identical-D8FxpvQU.js';
|
|
29
|
-
|
|
30
|
-
const ensureLinkSync = (source, destination) => {
|
|
31
|
-
assertValidFileOrDirectoryPath(source);
|
|
32
|
-
assertValidFileOrDirectoryPath(destination);
|
|
33
|
-
source = toNamespacedPath(toPath(source));
|
|
34
|
-
destination = toNamespacedPath(toPath(destination));
|
|
35
|
-
let destinationStat;
|
|
36
|
-
try {
|
|
37
|
-
destinationStat = lstatSync(destination);
|
|
38
|
-
} catch {
|
|
39
|
-
}
|
|
40
|
-
let sourceStat;
|
|
41
|
-
try {
|
|
42
|
-
sourceStat = lstatSync(source);
|
|
43
|
-
} catch (error) {
|
|
44
|
-
const nodeError = error;
|
|
45
|
-
nodeError.message = nodeError.message.replace("lstat", "ensureLink");
|
|
46
|
-
throw nodeError;
|
|
47
|
-
}
|
|
48
|
-
if (destinationStat && isStatsIdentical(sourceStat, destinationStat)) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
ensureDirSync(dirname(destination));
|
|
52
|
-
linkSync(source, destination);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export { ensureLinkSync as default };
|
|
@@ -1,80 +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
|
-
lstat,
|
|
22
|
-
stat,
|
|
23
|
-
symlink,
|
|
24
|
-
readlink
|
|
25
|
-
} = __cjs_getBuiltinModule("node:fs/promises");
|
|
26
|
-
import { toNamespacedPath, dirname, resolve } from '@visulima/path';
|
|
27
|
-
import { toPath } from '@visulima/path/utils';
|
|
28
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
29
|
-
import ensureDir from './ensureDir-DNlPftys.js';
|
|
30
|
-
import { g as getFileInfoType } from './get-file-info-type-FD4-jsyg.js';
|
|
31
|
-
import { i as isStatsIdentical } from './is-stats-identical-D8FxpvQU.js';
|
|
32
|
-
import { r as resolveSymlinkTarget } from './resolve-symlink-target-Kh4GovFf.js';
|
|
33
|
-
import AlreadyExistsError from './AlreadyExistsError-6Y9hjgMn.js';
|
|
34
|
-
|
|
35
|
-
const isWindows = process.platform === "win32" || /^(?:msys|cygwin)$/.test(process.env.OSTYPE);
|
|
36
|
-
const ensureSymlink = async (target, linkName, type) => {
|
|
37
|
-
assertValidFileOrDirectoryPath(target);
|
|
38
|
-
assertValidFileOrDirectoryPath(linkName);
|
|
39
|
-
const targetRealPath = resolveSymlinkTarget(target, linkName);
|
|
40
|
-
linkName = toNamespacedPath(toPath(linkName));
|
|
41
|
-
try {
|
|
42
|
-
const linkStatInfo = await lstat(linkName);
|
|
43
|
-
if (linkStatInfo.isSymbolicLink() && isStatsIdentical(await stat(targetRealPath), await stat(linkName))) {
|
|
44
|
-
const [sourceStat, destinationStat] = await Promise.all([stat(targetRealPath), stat(linkName)]);
|
|
45
|
-
if (isStatsIdentical(sourceStat, destinationStat)) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
} catch {
|
|
50
|
-
}
|
|
51
|
-
const sourceStatInfo = await lstat(targetRealPath);
|
|
52
|
-
const sourceFilePathType = getFileInfoType(sourceStatInfo);
|
|
53
|
-
await ensureDir(dirname(linkName));
|
|
54
|
-
let symlinkType = type ?? "file";
|
|
55
|
-
if (!type) {
|
|
56
|
-
if (isWindows) {
|
|
57
|
-
symlinkType = "junction";
|
|
58
|
-
} else {
|
|
59
|
-
symlinkType = sourceFilePathType === "dir" ? "dir" : "file";
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
try {
|
|
63
|
-
await symlink(toNamespacedPath(toPath(targetRealPath)), linkName, symlinkType);
|
|
64
|
-
} catch (error) {
|
|
65
|
-
if (error.code !== "EEXIST") {
|
|
66
|
-
throw error;
|
|
67
|
-
}
|
|
68
|
-
const linkStatInfo = await lstat(linkName);
|
|
69
|
-
if (!linkStatInfo.isSymbolicLink()) {
|
|
70
|
-
throw new AlreadyExistsError(`A ${String(getFileInfoType(linkStatInfo))} already exists at the path: ${linkName}`);
|
|
71
|
-
}
|
|
72
|
-
const linkPath = await readlink(linkName);
|
|
73
|
-
const linkRealPath = toNamespacedPath(resolve(linkPath));
|
|
74
|
-
if (linkRealPath !== targetRealPath) {
|
|
75
|
-
throw new AlreadyExistsError(`A symlink targeting to an undesired path already exists: ${linkName} -> ${linkRealPath}`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export { ensureSymlink as default };
|
|
@@ -1,81 +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
|
-
lstatSync,
|
|
22
|
-
statSync,
|
|
23
|
-
symlinkSync,
|
|
24
|
-
readlinkSync
|
|
25
|
-
} = __cjs_getBuiltinModule("node:fs");
|
|
26
|
-
import { toNamespacedPath, dirname, resolve } from '@visulima/path';
|
|
27
|
-
import { toPath } from '@visulima/path/utils';
|
|
28
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
29
|
-
import ensureDirSync from './ensureDirSync-DcPZFMy5.js';
|
|
30
|
-
import { g as getFileInfoType } from './get-file-info-type-FD4-jsyg.js';
|
|
31
|
-
import { i as isStatsIdentical } from './is-stats-identical-D8FxpvQU.js';
|
|
32
|
-
import { r as resolveSymlinkTarget } from './resolve-symlink-target-Kh4GovFf.js';
|
|
33
|
-
import AlreadyExistsError from './AlreadyExistsError-6Y9hjgMn.js';
|
|
34
|
-
|
|
35
|
-
const isWindows = process.platform === "win32" || /^(?:msys|cygwin)$/.test(process.env.OSTYPE);
|
|
36
|
-
const ensureSymlinkSync = (target, linkName, type) => {
|
|
37
|
-
assertValidFileOrDirectoryPath(target);
|
|
38
|
-
assertValidFileOrDirectoryPath(linkName);
|
|
39
|
-
const targetRealPath = resolveSymlinkTarget(target, linkName);
|
|
40
|
-
linkName = toNamespacedPath(toPath(linkName));
|
|
41
|
-
try {
|
|
42
|
-
const linkStatInfo = lstatSync(linkName);
|
|
43
|
-
if (linkStatInfo.isSymbolicLink() && isStatsIdentical(statSync(targetRealPath), statSync(linkName))) {
|
|
44
|
-
const sourceStat = statSync(targetRealPath);
|
|
45
|
-
const destinationStat = statSync(linkName);
|
|
46
|
-
if (isStatsIdentical(sourceStat, destinationStat)) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
} catch {
|
|
51
|
-
}
|
|
52
|
-
const sourceStatInfo = lstatSync(targetRealPath);
|
|
53
|
-
const sourceFilePathType = getFileInfoType(sourceStatInfo);
|
|
54
|
-
ensureDirSync(dirname(linkName));
|
|
55
|
-
let symlinkType = type ?? "file";
|
|
56
|
-
if (!type) {
|
|
57
|
-
if (isWindows) {
|
|
58
|
-
symlinkType = "junction";
|
|
59
|
-
} else {
|
|
60
|
-
symlinkType = sourceFilePathType === "dir" ? "dir" : "file";
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
try {
|
|
64
|
-
symlinkSync(toNamespacedPath(toPath(targetRealPath)), linkName, symlinkType);
|
|
65
|
-
} catch (error) {
|
|
66
|
-
if (error.code !== "EEXIST") {
|
|
67
|
-
throw error;
|
|
68
|
-
}
|
|
69
|
-
const linkStatInfo = lstatSync(linkName);
|
|
70
|
-
if (!linkStatInfo.isSymbolicLink()) {
|
|
71
|
-
throw new AlreadyExistsError(`A ${String(getFileInfoType(linkStatInfo))} already exists at the path: ${linkName}`);
|
|
72
|
-
}
|
|
73
|
-
const linkPath = readlinkSync(linkName);
|
|
74
|
-
const linkRealPath = toNamespacedPath(resolve(linkPath));
|
|
75
|
-
if (linkRealPath !== targetRealPath) {
|
|
76
|
-
throw new AlreadyExistsError(`A symlink targeting to an undesired path already exists: ${linkName} -> ${linkRealPath}`);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export { ensureSymlinkSync as default };
|
|
@@ -1,84 +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
|
-
stat,
|
|
22
|
-
lstat
|
|
23
|
-
} = __cjs_getBuiltinModule("node:fs/promises");
|
|
24
|
-
const {
|
|
25
|
-
fileURLToPath
|
|
26
|
-
} = __cjs_getBuiltinModule("node:url");
|
|
27
|
-
import { resolve, parse, isAbsolute, dirname } from '@visulima/path';
|
|
28
|
-
import { toPath } from '@visulima/path/utils';
|
|
29
|
-
import { FIND_UP_STOP } from './F_OK-MldBaGxb.js';
|
|
30
|
-
|
|
31
|
-
const findUp = async (name, options = {}) => {
|
|
32
|
-
if (typeof name !== "string" && !Array.isArray(name) && typeof name !== "function") {
|
|
33
|
-
throw new TypeError("The `name` argument must be of type `string` or `string[]`");
|
|
34
|
-
}
|
|
35
|
-
const cwd = options.cwd ? toPath(options.cwd) : process.cwd();
|
|
36
|
-
let directory = resolve(cwd);
|
|
37
|
-
const { root } = parse(directory);
|
|
38
|
-
const stopPath = toPath(options.stopAt ?? root);
|
|
39
|
-
const stopAt = resolve(directory, stopPath);
|
|
40
|
-
const type = options.type ?? "file";
|
|
41
|
-
const getMatchers = async function(currentDirectory) {
|
|
42
|
-
if (typeof name === "function") {
|
|
43
|
-
const match = await name(currentDirectory);
|
|
44
|
-
return [match];
|
|
45
|
-
}
|
|
46
|
-
if (typeof name === "string") {
|
|
47
|
-
return [name];
|
|
48
|
-
}
|
|
49
|
-
if (Array.isArray(name)) {
|
|
50
|
-
return name;
|
|
51
|
-
}
|
|
52
|
-
return [name];
|
|
53
|
-
};
|
|
54
|
-
options.allowSymlinks ??= true;
|
|
55
|
-
const statFunction = options.allowSymlinks ? stat : lstat;
|
|
56
|
-
while (directory && directory !== stopAt && directory !== root) {
|
|
57
|
-
const matchers = await getMatchers(directory);
|
|
58
|
-
for (let fileName of matchers) {
|
|
59
|
-
if (fileName === FIND_UP_STOP) {
|
|
60
|
-
return void 0;
|
|
61
|
-
}
|
|
62
|
-
if (fileName === void 0) {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
if (Buffer.isBuffer(fileName)) {
|
|
66
|
-
fileName = fileName.toString();
|
|
67
|
-
} else if (fileName instanceof URL) {
|
|
68
|
-
fileName = fileURLToPath(fileName);
|
|
69
|
-
}
|
|
70
|
-
const filePath = isAbsolute(fileName) ? fileName : resolve(directory, fileName);
|
|
71
|
-
try {
|
|
72
|
-
const stats = await statFunction(filePath);
|
|
73
|
-
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) {
|
|
74
|
-
return filePath;
|
|
75
|
-
}
|
|
76
|
-
} catch {
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
directory = dirname(directory);
|
|
80
|
-
}
|
|
81
|
-
return void 0;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export { findUp as default };
|
|
@@ -1,83 +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
|
-
statSync,
|
|
22
|
-
lstatSync
|
|
23
|
-
} = __cjs_getBuiltinModule("node:fs");
|
|
24
|
-
const {
|
|
25
|
-
fileURLToPath
|
|
26
|
-
} = __cjs_getBuiltinModule("node:url");
|
|
27
|
-
import { resolve, parse, isAbsolute, dirname } from '@visulima/path';
|
|
28
|
-
import { toPath } from '@visulima/path/utils';
|
|
29
|
-
import { FIND_UP_STOP } from './F_OK-MldBaGxb.js';
|
|
30
|
-
|
|
31
|
-
const findUpSync = (name, options = {}) => {
|
|
32
|
-
if (typeof name !== "string" && !Array.isArray(name) && typeof name !== "function") {
|
|
33
|
-
throw new TypeError("The `name` argument must be of type `string` or `string[]`");
|
|
34
|
-
}
|
|
35
|
-
const cwd = options.cwd ? toPath(options.cwd) : process.cwd();
|
|
36
|
-
let directory = resolve(cwd);
|
|
37
|
-
const { root } = parse(directory);
|
|
38
|
-
const stopPath = toPath(options.stopAt ?? root);
|
|
39
|
-
const stopAt = resolve(directory, stopPath);
|
|
40
|
-
const type = options.type ?? "file";
|
|
41
|
-
const getMatchers = function(currentDirectory) {
|
|
42
|
-
if (typeof name === "function") {
|
|
43
|
-
const match = name(currentDirectory);
|
|
44
|
-
return [match];
|
|
45
|
-
}
|
|
46
|
-
if (typeof name === "string") {
|
|
47
|
-
return [name];
|
|
48
|
-
}
|
|
49
|
-
if (Array.isArray(name)) {
|
|
50
|
-
return name;
|
|
51
|
-
}
|
|
52
|
-
return [name];
|
|
53
|
-
};
|
|
54
|
-
options.allowSymlinks ??= true;
|
|
55
|
-
const statFunction = options.allowSymlinks ? statSync : lstatSync;
|
|
56
|
-
while (directory && directory !== stopAt && directory !== root) {
|
|
57
|
-
for (let fileName of getMatchers(directory)) {
|
|
58
|
-
if (fileName === FIND_UP_STOP) {
|
|
59
|
-
return void 0;
|
|
60
|
-
}
|
|
61
|
-
if (fileName === void 0) {
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
if (Buffer.isBuffer(fileName)) {
|
|
65
|
-
fileName = fileName.toString();
|
|
66
|
-
} else if (fileName instanceof URL) {
|
|
67
|
-
fileName = fileURLToPath(fileName);
|
|
68
|
-
}
|
|
69
|
-
const filePath = isAbsolute(fileName) ? fileName : resolve(directory, fileName);
|
|
70
|
-
try {
|
|
71
|
-
const stats = statFunction(filePath);
|
|
72
|
-
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) {
|
|
73
|
-
return filePath;
|
|
74
|
-
}
|
|
75
|
-
} catch {
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
directory = dirname(directory);
|
|
79
|
-
}
|
|
80
|
-
return void 0;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export { findUpSync as default };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const getFileInfoType = (fileInfo) => {
|
|
2
|
-
if (fileInfo.isFile()) {
|
|
3
|
-
return "file";
|
|
4
|
-
}
|
|
5
|
-
if (fileInfo.isDirectory()) {
|
|
6
|
-
return "dir";
|
|
7
|
-
}
|
|
8
|
-
if (fileInfo.isSymbolicLink()) {
|
|
9
|
-
return "symlink";
|
|
10
|
-
}
|
|
11
|
-
return void 0;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { getFileInfoType as g };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { G as GlobOptions } from "./types.d-dP-lAGNn.js";
|
|
2
|
-
declare const glob: (patterns: string | ReadonlyArray<string>, options?: GlobOptions) => Promise<string[]>;
|
|
3
|
-
declare const globSync: (patterns: string | ReadonlyArray<string>, options?: GlobOptions) => string[];
|
|
4
|
-
export { globSync as a, glob as g };
|