@visulima/fs 4.0.3 → 4.0.5
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 +35 -0
- package/LICENSE.md +4 -1
- package/dist/constants.d.ts +42 -0
- package/dist/ensure/ensure-dir-sync.d.ts +14 -0
- package/dist/ensure/ensure-dir.d.ts +14 -0
- package/dist/ensure/ensure-file-sync.d.ts +15 -0
- package/dist/ensure/ensure-file.d.ts +27 -0
- package/dist/ensure/ensure-link-sync.d.ts +16 -0
- package/dist/ensure/ensure-link.d.ts +16 -0
- package/dist/ensure/ensure-symlink-sync.d.ts +23 -0
- package/dist/ensure/ensure-symlink.d.ts +23 -0
- package/dist/ensure/utils/get-file-info-type.d.ts +7 -0
- package/dist/ensure/utils/is-stats-identical.d.ts +3 -0
- package/dist/ensure/utils/resolve-symlink-target.d.ts +2 -0
- package/dist/eol.d.ts +35 -7
- package/dist/eol.js +26 -3
- package/dist/error/already-exists-error.d.ts +39 -0
- package/dist/error/directory-error.d.ts +47 -0
- package/dist/error/json-error.d.ts +52 -0
- package/dist/error/not-empty-error.d.ts +51 -0
- package/dist/error/not-found-error.d.ts +44 -0
- package/dist/error/permission-error.d.ts +45 -0
- package/dist/error/walk-error.d.ts +51 -0
- package/dist/error.d.ts +7 -50
- package/dist/error.js +7 -1
- package/dist/find/collect-sync.d.ts +31 -0
- package/dist/find/collect.d.ts +35 -0
- package/dist/find/find-up-sync.d.ts +42 -0
- package/dist/find/find-up.d.ts +46 -0
- package/dist/find/utils/glob-to-regex.d.ts +2 -0
- package/dist/find/utils/walk-include.d.ts +2 -0
- package/dist/find/walk-sync.d.ts +26 -0
- package/dist/find/walk.d.ts +29 -0
- package/dist/index.d.ts +34 -136
- package/dist/index.js +32 -1
- package/dist/is-accessible-sync.d.ts +3 -0
- package/dist/is-accessible.d.ts +29 -0
- package/dist/move/index.d.ts +70 -0
- package/dist/move/types.d.ts +38 -0
- package/dist/move/utils/internal-move-file-sync.d.ts +3 -0
- package/dist/move/utils/internal-move-file.d.ts +3 -0
- package/dist/move/utils/validate-same-directory.d.ts +2 -0
- package/dist/packem_shared/AlreadyExistsError-D5BGeeNR.js +27 -0
- package/dist/packem_shared/DirectoryError-CaUV2Pbk.js +27 -0
- package/dist/packem_shared/F_OK-BalxCn9n.js +8 -0
- package/dist/packem_shared/JSONError-BkHRnInH.js +26 -0
- package/dist/packem_shared/NotEmptyError-mOHWXE0m.js +27 -0
- package/dist/packem_shared/NotFoundError-D4llRgRs.js +27 -0
- package/dist/packem_shared/PermissionError-1qs0skfo.js +27 -0
- package/dist/packem_shared/WalkError-DUdQd6FT.js +24 -0
- package/dist/packem_shared/assertValidFileContents-BmcLtsGd.js +7 -0
- package/dist/packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js +7 -0
- package/dist/packem_shared/collect-DcBwsYYd.js +14 -0
- package/dist/packem_shared/collectSync-Bkjf9Dbm.js +14 -0
- package/dist/packem_shared/emptyDir-CYB5Tict.js +43 -0
- package/dist/packem_shared/emptyDirSync-BD8-1Ytl.js +41 -0
- package/dist/packem_shared/ensureDir-C_kuQ5Ik.js +53 -0
- package/dist/packem_shared/ensureDirSync-CI5g-uBI.js +53 -0
- package/dist/packem_shared/ensureFile-BUtXGlGT.js +47 -0
- package/dist/packem_shared/ensureFileSync-C8hASR-1.js +47 -0
- package/dist/packem_shared/ensureLink-BPnAG5-P.js +54 -0
- package/dist/packem_shared/ensureLinkSync-B-Z7X0ub.js +54 -0
- package/dist/packem_shared/ensureSymlink-BGz6W-Wa.js +73 -0
- package/dist/packem_shared/ensureSymlinkSync-C5Gk8QYi.js +74 -0
- package/dist/packem_shared/findUp-Lv9mZCIQ.js +85 -0
- package/dist/packem_shared/findUpSync-BsK4Nrrq.js +85 -0
- package/dist/packem_shared/get-file-info-type-FD4-jsyg.js +14 -0
- package/dist/packem_shared/index-CHM-in-V.js +100 -0
- package/dist/packem_shared/is-stats-identical-D8FxpvQU.js +3 -0
- package/dist/packem_shared/isAccessible-iOp0Bou6.js +38 -0
- package/dist/packem_shared/isAccessibleSync-38BmiIcx.js +38 -0
- package/dist/packem_shared/isFsCaseSensitive-D-ayleCy.js +62 -0
- package/dist/packem_shared/move-BD6JbYSu.js +134 -0
- package/dist/packem_shared/parseJson-CqUuRguZ.js +231 -0
- package/dist/packem_shared/readFile-XVOjAw8r.js +65 -0
- package/dist/packem_shared/readFileSync-B9Zg5PSF.js +53 -0
- package/dist/packem_shared/readJson-Dra2m6s-.js +22 -0
- package/dist/packem_shared/readJsonSync-B6Dl1I_6.js +22 -0
- package/dist/packem_shared/readYaml-Bu1nsexB.js +10 -0
- package/dist/packem_shared/readYamlSync-Di88aMME.js +10 -0
- package/dist/packem_shared/remove-_oDY3uKo.js +38 -0
- package/dist/packem_shared/removeSync-DETRj7Qn.js +38 -0
- package/dist/packem_shared/resolve-symlink-target-Kh4GovFf.js +16 -0
- package/dist/packem_shared/stripJsonComments-21XWVDwP.js +19 -0
- package/dist/packem_shared/to-uint-8-array-Dz2nF1y1.js +19 -0
- package/dist/packem_shared/walk-BhTbpr3y.js +115 -0
- package/dist/packem_shared/walk-include-CZco7BvN.js +16 -0
- package/dist/packem_shared/walkSync-DDBq95s8.js +114 -0
- package/dist/packem_shared/writeFile-NT1fLEEe.js +83 -0
- package/dist/packem_shared/writeFileSync-Bj5UDSf0.js +83 -0
- package/dist/packem_shared/writeJson-DQLdAi0d.js +50 -0
- package/dist/packem_shared/writeJsonSync-DvTCjVUi.js +50 -0
- package/dist/packem_shared/writeYaml-BMY0kOPf.js +24 -0
- package/dist/packem_shared/writeYamlSync-DqPu8cCd.js +24 -0
- package/dist/read/read-file-sync.d.ts +37 -0
- package/dist/read/read-file.d.ts +41 -0
- package/dist/read/read-json-sync.d.ts +5 -0
- package/dist/read/read-json.d.ts +5 -0
- package/dist/read/read-yaml-sync.d.ts +4 -0
- package/dist/read/read-yaml.d.ts +4 -0
- package/dist/remove/empty-dir-sync.d.ts +24 -0
- package/dist/remove/empty-dir.d.ts +28 -0
- package/dist/remove/remove-sync.d.ts +28 -0
- package/dist/remove/remove.d.ts +32 -0
- package/dist/size.d.ts +245 -12
- package/dist/size.js +144 -1
- package/dist/types.d.ts +299 -0
- package/dist/utils/assert-valid-file-contents.d.ts +27 -0
- package/dist/utils/assert-valid-file-or-directory-path.d.ts +26 -0
- package/dist/utils/parse-json.d.ts +5 -0
- package/dist/utils/strip-json-comments.d.ts +44 -0
- package/dist/utils.d.ts +6 -19
- package/dist/utils.js +6 -1
- package/dist/write/utils/to-uint-8-array.d.ts +2 -0
- package/dist/write/write-file-sync.d.ts +30 -0
- package/dist/write/write-file.d.ts +30 -0
- package/dist/write/write-json-sync.d.ts +30 -0
- package/dist/write/write-json.d.ts +30 -0
- package/dist/write/write-yaml-sync.d.ts +4 -0
- package/dist/write/write-yaml.d.ts +4 -0
- package/dist/yaml.d.ts +5 -17
- package/dist/yaml.js +4 -1
- package/package.json +2 -3
- package/dist/packem_shared/AlreadyExistsError-CEu6_Tjb.js +0 -1
- package/dist/packem_shared/DirectoryError-ddlbUV8C.js +0 -1
- package/dist/packem_shared/F_OK-CAwY1qU7.js +0 -1
- package/dist/packem_shared/JSONError-D7h6PNWc.js +0 -4
- package/dist/packem_shared/NotEmptyError-DMh1o7UL.js +0 -1
- package/dist/packem_shared/NotFoundError-BPiW0icm.js +0 -1
- package/dist/packem_shared/PermissionError-B1Emi5a9.js +0 -1
- package/dist/packem_shared/WalkError-BsngoIKJ.js +0 -1
- package/dist/packem_shared/assertValidFileContents-BZFnXa7K.js +0 -1
- package/dist/packem_shared/assertValidFileOrDirectoryPath-DgPIPmZT.js +0 -1
- package/dist/packem_shared/collect-DO31RsLs.js +0 -1
- package/dist/packem_shared/collectSync-Cy7ULmjZ.js +0 -1
- package/dist/packem_shared/emptyDir-zBLHyPsJ.js +0 -1
- package/dist/packem_shared/emptyDirSync-DZ8nTo6g.js +0 -1
- package/dist/packem_shared/ensureDir-CwcwvbZ0.js +0 -1
- package/dist/packem_shared/ensureDirSync-DsFhH5oQ.js +0 -1
- package/dist/packem_shared/ensureFile-DwcEQVDX.js +0 -1
- package/dist/packem_shared/ensureFileSync-KnrH51Ox.js +0 -1
- package/dist/packem_shared/ensureLink-5rjQGEBb.js +0 -1
- package/dist/packem_shared/ensureLinkSync-CYXpscf2.js +0 -1
- package/dist/packem_shared/ensureSymlink-GATTbE5c.js +0 -1
- package/dist/packem_shared/ensureSymlinkSync-CvXgTFrl.js +0 -1
- package/dist/packem_shared/findUp-Di7Az07S.js +0 -1
- package/dist/packem_shared/findUpSync-iV97v14Q.js +0 -1
- package/dist/packem_shared/get-file-info-type-CaWGXRjY.js +0 -1
- package/dist/packem_shared/index-CYIVJA0W.js +0 -1
- package/dist/packem_shared/is-stats-identical-CohsLtWy.js +0 -1
- package/dist/packem_shared/isAccessible-CDFxsAAo.js +0 -1
- package/dist/packem_shared/isAccessibleSync-5nzZWgin.js +0 -1
- package/dist/packem_shared/isFsCaseSensitive-Drl8fHLV.js +0 -1
- package/dist/packem_shared/json-error-ZPgZIXcg.d.ts +0 -11
- package/dist/packem_shared/move-Bz4gSIjp.js +0 -1
- package/dist/packem_shared/parseJson-Cj4v3qzl.js +0 -6
- package/dist/packem_shared/readFile-CbxFM_zp.js +0 -1
- package/dist/packem_shared/readFileSync-B9iv2Sb8.js +0 -1
- package/dist/packem_shared/readJson-BgC3msx-.js +0 -1
- package/dist/packem_shared/readJsonSync-DHO1vjAG.js +0 -1
- package/dist/packem_shared/readYaml-D5mtfANg.js +0 -1
- package/dist/packem_shared/readYamlSync-D0igCVDE.js +0 -1
- package/dist/packem_shared/remove-BUqZUj1W.js +0 -1
- package/dist/packem_shared/removeSync-BbT4vmDi.js +0 -1
- package/dist/packem_shared/resolve-symlink-target-BofZSDIc.js +0 -1
- package/dist/packem_shared/stripJsonComments-DbMjL4qv.js +0 -1
- package/dist/packem_shared/to-uint-8-array-DwgaTasY.js +0 -1
- package/dist/packem_shared/types-T308NKwz.d.ts +0 -90
- package/dist/packem_shared/walk-ZrZngpc4.js +0 -1
- package/dist/packem_shared/walk-include-DCiVAwMP.js +0 -1
- package/dist/packem_shared/walkSync-BQa4NKSG.js +0 -1
- package/dist/packem_shared/writeFile-D5OYEMHu.js +0 -1
- package/dist/packem_shared/writeFileSync-CO4ySqUn.js +0 -1
- package/dist/packem_shared/writeJson-DfmgiY_s.js +0 -4
- package/dist/packem_shared/writeJsonSync-Ck1pmmj_.js +0 -4
- package/dist/packem_shared/writeYaml-BJeyUpyY.js +0 -1
- package/dist/packem_shared/writeYamlSync-D87XCS7Y.js +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
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-C_kuQ5Ik.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
|
+
error.message = error.message.replace("lstat", "ensureLink");
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
if (destinationStat && isStatsIdentical(sourceStat, destinationStat)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
await ensureDir(dirname(destination));
|
|
51
|
+
await link(source, destination);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { ensureLink as default };
|
|
@@ -0,0 +1,54 @@
|
|
|
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-CI5g-uBI.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
|
+
error.message = error.message.replace("lstat", "ensureLink");
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
if (destinationStat && isStatsIdentical(sourceStat, destinationStat)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
ensureDirSync(dirname(destination));
|
|
51
|
+
linkSync(source, destination);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { ensureLinkSync as default };
|
|
@@ -0,0 +1,73 @@
|
|
|
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-C_kuQ5Ik.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-D5BGeeNR.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
|
+
const symlinkType = type ?? (isWindows ? "junction" : sourceFilePathType === "dir" ? "dir" : "file");
|
|
55
|
+
try {
|
|
56
|
+
await symlink(toNamespacedPath(toPath(targetRealPath)), linkName, symlinkType);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
if (error.code !== "EEXIST") {
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
const linkStatInfo = await lstat(linkName);
|
|
62
|
+
if (!linkStatInfo.isSymbolicLink()) {
|
|
63
|
+
throw new AlreadyExistsError(`A ${getFileInfoType(linkStatInfo)} already exists at the path: ${linkName}`);
|
|
64
|
+
}
|
|
65
|
+
const linkPath = await readlink(linkName);
|
|
66
|
+
const linkRealPath = toNamespacedPath(resolve(linkPath));
|
|
67
|
+
if (linkRealPath !== targetRealPath) {
|
|
68
|
+
throw new AlreadyExistsError(`A symlink targeting to an undesired path already exists: ${linkName} -> ${linkRealPath}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export { ensureSymlink as default };
|
|
@@ -0,0 +1,74 @@
|
|
|
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-CI5g-uBI.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-D5BGeeNR.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
|
+
const symlinkType = type ?? (isWindows ? "junction" : sourceFilePathType === "dir" ? "dir" : "file");
|
|
56
|
+
try {
|
|
57
|
+
symlinkSync(toNamespacedPath(toPath(targetRealPath)), linkName, symlinkType);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
if (error.code !== "EEXIST") {
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
const linkStatInfo = lstatSync(linkName);
|
|
63
|
+
if (!linkStatInfo.isSymbolicLink()) {
|
|
64
|
+
throw new AlreadyExistsError(`A ${getFileInfoType(linkStatInfo)} already exists at the path: ${linkName}`);
|
|
65
|
+
}
|
|
66
|
+
const linkPath = readlinkSync(linkName);
|
|
67
|
+
const linkRealPath = toNamespacedPath(resolve(linkPath));
|
|
68
|
+
if (linkRealPath !== targetRealPath) {
|
|
69
|
+
throw new AlreadyExistsError(`A symlink targeting to an undesired path already exists: ${linkName} -> ${linkRealPath}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { ensureSymlinkSync as default };
|
|
@@ -0,0 +1,85 @@
|
|
|
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-BalxCn9n.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
|
+
if (options.allowSymlinks === void 0) {
|
|
55
|
+
options.allowSymlinks = true;
|
|
56
|
+
}
|
|
57
|
+
const statFunction = options.allowSymlinks ? stat : lstat;
|
|
58
|
+
while (directory && directory !== stopAt && directory !== root) {
|
|
59
|
+
for await (let fileName of await getMatchers(directory)) {
|
|
60
|
+
if (fileName === FIND_UP_STOP) {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
if (fileName === void 0) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (Buffer.isBuffer(fileName)) {
|
|
67
|
+
fileName = fileName.toString();
|
|
68
|
+
} else if (fileName instanceof URL) {
|
|
69
|
+
fileName = fileURLToPath(fileName);
|
|
70
|
+
}
|
|
71
|
+
const filePath = isAbsolute(fileName) ? fileName : resolve(directory, fileName);
|
|
72
|
+
try {
|
|
73
|
+
const stats = await statFunction(filePath);
|
|
74
|
+
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) {
|
|
75
|
+
return filePath;
|
|
76
|
+
}
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
directory = dirname(directory);
|
|
81
|
+
}
|
|
82
|
+
return void 0;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export { findUp as default };
|
|
@@ -0,0 +1,85 @@
|
|
|
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-BalxCn9n.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
|
+
if (options.allowSymlinks === void 0) {
|
|
55
|
+
options.allowSymlinks = true;
|
|
56
|
+
}
|
|
57
|
+
const statFunction = options.allowSymlinks ? statSync : lstatSync;
|
|
58
|
+
while (directory && directory !== stopAt && directory !== root) {
|
|
59
|
+
for (let fileName of getMatchers(directory)) {
|
|
60
|
+
if (fileName === FIND_UP_STOP) {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
if (fileName === void 0) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (Buffer.isBuffer(fileName)) {
|
|
67
|
+
fileName = fileName.toString();
|
|
68
|
+
} else if (fileName instanceof URL) {
|
|
69
|
+
fileName = fileURLToPath(fileName);
|
|
70
|
+
}
|
|
71
|
+
const filePath = isAbsolute(fileName) ? fileName : resolve(directory, fileName);
|
|
72
|
+
try {
|
|
73
|
+
const stats = statFunction(filePath);
|
|
74
|
+
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) {
|
|
75
|
+
return filePath;
|
|
76
|
+
}
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
directory = dirname(directory);
|
|
81
|
+
}
|
|
82
|
+
return void 0;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export { findUpSync as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
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 };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
const INDENT_REGEX = /^(?:( )+|\t+)/;
|
|
2
|
+
const INDENT_TYPE_SPACE = "space";
|
|
3
|
+
const INDENT_TYPE_TAB = "tab";
|
|
4
|
+
function shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, value) {
|
|
5
|
+
return ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && value === 1;
|
|
6
|
+
}
|
|
7
|
+
function makeIndentsMap(string, ignoreSingleSpaces) {
|
|
8
|
+
const indents = /* @__PURE__ */ new Map();
|
|
9
|
+
let previousSize = 0;
|
|
10
|
+
let previousIndentType;
|
|
11
|
+
let key;
|
|
12
|
+
for (const line of string.split(/\n/g)) {
|
|
13
|
+
if (!line) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const matches = line.match(INDENT_REGEX);
|
|
17
|
+
if (matches === null) {
|
|
18
|
+
previousSize = 0;
|
|
19
|
+
previousIndentType = "";
|
|
20
|
+
} else {
|
|
21
|
+
const indent = matches[0].length;
|
|
22
|
+
const indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
|
|
23
|
+
if (shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, indent)) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (indentType !== previousIndentType) {
|
|
27
|
+
previousSize = 0;
|
|
28
|
+
}
|
|
29
|
+
previousIndentType = indentType;
|
|
30
|
+
let use = 1;
|
|
31
|
+
let weight = 0;
|
|
32
|
+
const indentDifference = indent - previousSize;
|
|
33
|
+
previousSize = indent;
|
|
34
|
+
if (indentDifference === 0) {
|
|
35
|
+
use = 0;
|
|
36
|
+
weight = 1;
|
|
37
|
+
} else {
|
|
38
|
+
const absoluteIndentDifference = Math.abs(indentDifference);
|
|
39
|
+
if (shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, absoluteIndentDifference)) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
key = encodeIndentsKey(indentType, absoluteIndentDifference);
|
|
43
|
+
}
|
|
44
|
+
const entry = indents.get(key);
|
|
45
|
+
indents.set(key, entry === void 0 ? [1, 0] : [entry[0] + use, entry[1] + weight]);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return indents;
|
|
49
|
+
}
|
|
50
|
+
function encodeIndentsKey(indentType, indentAmount) {
|
|
51
|
+
const typeCharacter = indentType === INDENT_TYPE_SPACE ? "s" : "t";
|
|
52
|
+
return typeCharacter + String(indentAmount);
|
|
53
|
+
}
|
|
54
|
+
function decodeIndentsKey(indentsKey) {
|
|
55
|
+
const keyHasTypeSpace = indentsKey[0] === "s";
|
|
56
|
+
const type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
|
|
57
|
+
const amount = Number(indentsKey.slice(1));
|
|
58
|
+
return { type, amount };
|
|
59
|
+
}
|
|
60
|
+
function getMostUsedKey(indents) {
|
|
61
|
+
let result;
|
|
62
|
+
let maxUsed = 0;
|
|
63
|
+
let maxWeight = 0;
|
|
64
|
+
for (const [key, [usedCount, weight]] of indents) {
|
|
65
|
+
if (usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) {
|
|
66
|
+
maxUsed = usedCount;
|
|
67
|
+
maxWeight = weight;
|
|
68
|
+
result = key;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
function makeIndentString(type, amount) {
|
|
74
|
+
const indentCharacter = type === INDENT_TYPE_SPACE ? " " : " ";
|
|
75
|
+
return indentCharacter.repeat(amount);
|
|
76
|
+
}
|
|
77
|
+
function detectIndent(string) {
|
|
78
|
+
if (typeof string !== "string") {
|
|
79
|
+
throw new TypeError("Expected a string");
|
|
80
|
+
}
|
|
81
|
+
let indents = makeIndentsMap(string, true);
|
|
82
|
+
if (indents.size === 0) {
|
|
83
|
+
indents = makeIndentsMap(string, false);
|
|
84
|
+
}
|
|
85
|
+
const keyOfMostUsedIndent = getMostUsedKey(indents);
|
|
86
|
+
let type;
|
|
87
|
+
let amount = 0;
|
|
88
|
+
let indent = "";
|
|
89
|
+
if (keyOfMostUsedIndent !== void 0) {
|
|
90
|
+
({ type, amount } = decodeIndentsKey(keyOfMostUsedIndent));
|
|
91
|
+
indent = makeIndentString(type, amount);
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
amount,
|
|
95
|
+
type,
|
|
96
|
+
indent
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { detectIndent as d };
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
access
|
|
22
|
+
} = __cjs_getBuiltinModule("node:fs/promises");
|
|
23
|
+
import { toPath } from '@visulima/path/utils';
|
|
24
|
+
import { F_OK } from './F_OK-BalxCn9n.js';
|
|
25
|
+
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
26
|
+
|
|
27
|
+
async function isAccessible(path, mode = F_OK) {
|
|
28
|
+
assertValidFileOrDirectoryPath(path);
|
|
29
|
+
path = toPath(path);
|
|
30
|
+
try {
|
|
31
|
+
await access(path, mode);
|
|
32
|
+
return true;
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { isAccessible as default };
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
accessSync
|
|
22
|
+
} = __cjs_getBuiltinModule("node:fs");
|
|
23
|
+
import { toPath } from '@visulima/path/utils';
|
|
24
|
+
import { F_OK } from './F_OK-BalxCn9n.js';
|
|
25
|
+
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
26
|
+
|
|
27
|
+
function isAccessibleSync(path, mode = F_OK) {
|
|
28
|
+
assertValidFileOrDirectoryPath(path);
|
|
29
|
+
path = toPath(path);
|
|
30
|
+
try {
|
|
31
|
+
accessSync(path, mode);
|
|
32
|
+
return true;
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { isAccessibleSync as default };
|