@visulima/fs 3.1.6 → 3.1.8
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 +22 -0
- package/LICENSE.md +125 -0
- package/README.md +153 -153
- package/dist/eol.cjs +3 -28
- package/dist/eol.mjs +3 -20
- package/dist/error.cjs +1 -21
- package/dist/error.mjs +1 -7
- package/dist/index.cjs +1 -80
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +1 -31
- package/dist/packem_shared/AlreadyExistsError-CEu6_Tjb.mjs +1 -0
- package/dist/packem_shared/AlreadyExistsError-GC2XUgzJ.cjs +1 -0
- package/dist/packem_shared/DirectoryError-aGtmQVph.cjs +1 -0
- package/dist/packem_shared/DirectoryError-ddlbUV8C.mjs +1 -0
- package/dist/packem_shared/F_OK-7T91O6Oz.cjs +1 -0
- package/dist/packem_shared/F_OK-B71i3mUa.mjs +1 -0
- package/dist/packem_shared/JSONError-CVkb3xZ3.mjs +4 -0
- package/dist/packem_shared/JSONError-CWuiGmNc.cjs +4 -0
- package/dist/packem_shared/NotEmptyError-BWGfec5K.cjs +1 -0
- package/dist/packem_shared/NotEmptyError-DMh1o7UL.mjs +1 -0
- package/dist/packem_shared/NotFoundError-BPiW0icm.mjs +1 -0
- package/dist/packem_shared/NotFoundError-Diij7oqe.cjs +1 -0
- package/dist/packem_shared/PermissionError-B1Emi5a9.mjs +1 -0
- package/dist/packem_shared/PermissionError-Ck1Es7al.cjs +1 -0
- package/dist/packem_shared/WalkError-BsngoIKJ.mjs +1 -0
- package/dist/packem_shared/WalkError-gKgp0TWD.cjs +1 -0
- package/dist/packem_shared/assertValidFileContents-BZFnXa7K.mjs +1 -0
- package/dist/packem_shared/assertValidFileContents-CrbDz09d.cjs +1 -0
- package/dist/packem_shared/assertValidFileOrDirectoryPath-DgPIPmZT.mjs +1 -0
- package/dist/packem_shared/assertValidFileOrDirectoryPath-HOUs73Jk.cjs +1 -0
- package/dist/packem_shared/collect-Bl2Oc1qs.cjs +1 -0
- package/dist/packem_shared/collect-CyYPQFMs.mjs +1 -0
- package/dist/packem_shared/collectSync-BHjyXWq4.cjs +1 -0
- package/dist/packem_shared/collectSync-CD9cXw2g.mjs +1 -0
- package/dist/packem_shared/emptyDir-BdjO-6Gu.mjs +1 -0
- package/dist/packem_shared/emptyDir-DGRw4yE9.cjs +1 -0
- package/dist/packem_shared/emptyDirSync-C1vsMEp-.mjs +1 -0
- package/dist/packem_shared/emptyDirSync-DzjDZxOx.cjs +1 -0
- package/dist/packem_shared/ensureDir-BuIFF_6B.mjs +1 -0
- package/dist/packem_shared/ensureDir-DtQzyA70.cjs +1 -0
- package/dist/packem_shared/ensureDirSync-BuPHxdP4.mjs +1 -0
- package/dist/packem_shared/ensureDirSync-C8hIoS3o.cjs +1 -0
- package/dist/packem_shared/ensureFile-DcAODM6a.mjs +1 -0
- package/dist/packem_shared/ensureFile-wR8zBfXh.cjs +1 -0
- package/dist/packem_shared/ensureFileSync-BI1fIdNf.cjs +1 -0
- package/dist/packem_shared/ensureFileSync-CzPN6ucX.mjs +1 -0
- package/dist/packem_shared/ensureLink-BaZLXxgx.mjs +1 -0
- package/dist/packem_shared/ensureLink-DCPuU0Za.cjs +1 -0
- package/dist/packem_shared/ensureLinkSync-9C2JL-Sl.mjs +1 -0
- package/dist/packem_shared/ensureLinkSync-CuRZmQlV.cjs +1 -0
- package/dist/packem_shared/ensureSymlink-BH6wbylb.mjs +1 -0
- package/dist/packem_shared/ensureSymlink-J83jhdfA.cjs +1 -0
- package/dist/packem_shared/ensureSymlinkSync-CZSPodAm.mjs +1 -0
- package/dist/packem_shared/ensureSymlinkSync-VNtMTaV8.cjs +1 -0
- package/dist/packem_shared/findUp-C5aWsLuD.cjs +1 -0
- package/dist/packem_shared/findUp-CMGMYNty.mjs +1 -0
- package/dist/packem_shared/findUpSync-QP_ZEsJN.mjs +1 -0
- package/dist/packem_shared/findUpSync-U1lTgv4y.cjs +1 -0
- package/dist/packem_shared/get-file-info-type-CaWGXRjY.mjs +1 -0
- package/dist/packem_shared/get-file-info-type-DDbpRlDl.cjs +1 -0
- package/dist/packem_shared/index-BSjF-5vj.mjs +1 -0
- package/dist/packem_shared/index-DPla58ce.cjs +1 -0
- package/dist/packem_shared/is-stats-identical-Bti7K05l.cjs +1 -0
- package/dist/packem_shared/is-stats-identical-CohsLtWy.mjs +1 -0
- package/dist/packem_shared/isAccessible-BQZd1_xn.cjs +1 -0
- package/dist/packem_shared/isAccessible-CL4eE5VL.mjs +1 -0
- package/dist/packem_shared/isAccessibleSync-BP5N8k_-.cjs +1 -0
- package/dist/packem_shared/isAccessibleSync-_HU_ppdG.mjs +1 -0
- package/dist/packem_shared/move--o4NZLpD.mjs +1 -0
- package/dist/packem_shared/move-DwG6APiG.cjs +1 -0
- package/dist/packem_shared/parseJson-B_GwHpKj.cjs +6 -0
- package/dist/packem_shared/parseJson-Bqic0nN8.mjs +6 -0
- package/dist/packem_shared/readFile-BvefDyr_.cjs +1 -0
- package/dist/packem_shared/readFile-Cix_ijtX.mjs +1 -0
- package/dist/packem_shared/readFileSync-B0O-8BH0.mjs +1 -0
- package/dist/packem_shared/readFileSync-Ct8Ql4Vs.cjs +1 -0
- package/dist/packem_shared/readJson-BLvd2Bsj.mjs +1 -0
- package/dist/packem_shared/readJson-cP5ArpPg.cjs +1 -0
- package/dist/packem_shared/readJsonSync-B6h6A3Un.cjs +1 -0
- package/dist/packem_shared/readJsonSync-Br5dHGAI.mjs +1 -0
- package/dist/packem_shared/readYaml-BOYTR5D1.mjs +1 -0
- package/dist/packem_shared/readYaml-BzMFDsYe.cjs +1 -0
- package/dist/packem_shared/readYamlSync-BbK0khJu.cjs +1 -0
- package/dist/packem_shared/readYamlSync-md9g88k7.mjs +1 -0
- package/dist/packem_shared/remove-CtnFqEpd.mjs +1 -0
- package/dist/packem_shared/remove-DPCf2Qdb.cjs +1 -0
- package/dist/packem_shared/removeSync-Cyriz7r8.cjs +1 -0
- package/dist/packem_shared/removeSync-DI-IjqVp.mjs +1 -0
- package/dist/packem_shared/resolve-symlink-target-BofZSDIc.mjs +1 -0
- package/dist/packem_shared/resolve-symlink-target-zilkQ_AU.cjs +1 -0
- package/dist/packem_shared/stripJsonComments-Cp5SNAB7.mjs +1 -0
- package/dist/packem_shared/stripJsonComments-CvZSDnYT.cjs +1 -0
- package/dist/packem_shared/to-uint-8-array-2-3EvGd7.cjs +1 -0
- package/dist/packem_shared/to-uint-8-array-DwgaTasY.mjs +1 -0
- package/dist/packem_shared/{types-BaMGfHdp.d.ts → types-XsSUZ9oS.d.cts} +1 -1
- package/dist/packem_shared/{types-BaMGfHdp.d.mts → types-XsSUZ9oS.d.mts} +1 -1
- package/dist/packem_shared/{types-BaMGfHdp.d.cts → types-XsSUZ9oS.d.ts} +1 -1
- package/dist/packem_shared/walk-BZTXbT87.mjs +1 -0
- package/dist/packem_shared/walk-DyN_HVFW.cjs +1 -0
- package/dist/packem_shared/walk-include-C9pVST87.mjs +1 -0
- package/dist/packem_shared/walk-include-DkK-WJl4.cjs +1 -0
- package/dist/packem_shared/walkSync-BHlEzV_m.mjs +1 -0
- package/dist/packem_shared/walkSync-Bqi7L2yG.cjs +1 -0
- package/dist/packem_shared/writeFile-COOAkvOE.mjs +1 -0
- package/dist/packem_shared/writeFile-CjgQEfur.cjs +1 -0
- package/dist/packem_shared/writeFileSync-CQuRHo9n.cjs +1 -0
- package/dist/packem_shared/writeFileSync-rhu-y_zx.mjs +1 -0
- package/dist/packem_shared/writeJson-BYT4WInm.mjs +4 -0
- package/dist/packem_shared/writeJson-CJIciZ_Q.cjs +4 -0
- package/dist/packem_shared/writeJsonSync-BIsrhRbV.cjs +4 -0
- package/dist/packem_shared/writeJsonSync-CLlXOFDm.mjs +4 -0
- package/dist/packem_shared/writeYaml-CjzVd0K-.mjs +1 -0
- package/dist/packem_shared/writeYaml-VmX1VKhN.cjs +1 -0
- package/dist/packem_shared/writeYamlSync-D9A9Ixe1.mjs +1 -0
- package/dist/packem_shared/writeYamlSync-DYsM6XBi.cjs +1 -0
- package/dist/size.cjs +1 -118
- package/dist/size.mjs +1 -109
- package/dist/utils.cjs +1 -19
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.mjs +1 -6
- package/dist/yaml.cjs +1 -15
- package/dist/yaml.d.cts +1 -1
- package/dist/yaml.d.mts +1 -1
- package/dist/yaml.d.ts +1 -1
- package/dist/yaml.mjs +1 -4
- package/package.json +1 -1
- package/dist/packem_shared/AlreadyExistsError-DpxtwQot.cjs +0 -34
- package/dist/packem_shared/AlreadyExistsError-GK7J9fVA.mjs +0 -32
- package/dist/packem_shared/DirectoryError-D8FHcAqu.cjs +0 -34
- package/dist/packem_shared/DirectoryError-DByTWE7t.mjs +0 -32
- package/dist/packem_shared/F_OK-CWSqQIdF.cjs +0 -17
- package/dist/packem_shared/F_OK-JER1LjUr.mjs +0 -8
- package/dist/packem_shared/JSONError-5-wHnrxX.cjs +0 -34
- package/dist/packem_shared/JSONError-CaKt7MhC.mjs +0 -32
- package/dist/packem_shared/NotEmptyError-BCS_5pPt.cjs +0 -34
- package/dist/packem_shared/NotEmptyError-DCXooh5l.mjs +0 -32
- package/dist/packem_shared/NotFoundError-B_1nPl3K.cjs +0 -34
- package/dist/packem_shared/NotFoundError-CUdcC61I.mjs +0 -32
- package/dist/packem_shared/PermissionError-CqGMI9qC.mjs +0 -32
- package/dist/packem_shared/PermissionError-QFMKgk2l.cjs +0 -34
- package/dist/packem_shared/WalkError-B4-yr8Kk.cjs +0 -31
- package/dist/packem_shared/WalkError-DvEBTTaj.mjs +0 -29
- package/dist/packem_shared/assertValidFileContents-CRVvyM6b.cjs +0 -11
- package/dist/packem_shared/assertValidFileContents-Ox-ScfeK.mjs +0 -9
- package/dist/packem_shared/assertValidFileOrDirectoryPath-BMbgA-eI.cjs +0 -11
- package/dist/packem_shared/assertValidFileOrDirectoryPath-BWWgA1wj.mjs +0 -9
- package/dist/packem_shared/collect-3Paj1Vqw.mjs +0 -16
- package/dist/packem_shared/collect-DnfQeSOL.cjs +0 -18
- package/dist/packem_shared/collectSync-D4vym4QD.cjs +0 -18
- package/dist/packem_shared/collectSync-DwJLL8SD.mjs +0 -16
- package/dist/packem_shared/emptyDir-DcCfiNcf.cjs +0 -22
- package/dist/packem_shared/emptyDir-Dw5xSBox.mjs +0 -20
- package/dist/packem_shared/emptyDirSync-BWA4n6TB.cjs +0 -21
- package/dist/packem_shared/emptyDirSync-DMAaCiC_.mjs +0 -19
- package/dist/packem_shared/ensureDir-BOfUZlxG.cjs +0 -35
- package/dist/packem_shared/ensureDir-BnA_fY1A.mjs +0 -33
- package/dist/packem_shared/ensureDirSync-DHmWi3CF.cjs +0 -35
- package/dist/packem_shared/ensureDirSync-Dm4az3YF.mjs +0 -33
- package/dist/packem_shared/ensureFile-BKrJMHfr.mjs +0 -27
- package/dist/packem_shared/ensureFile-CeGryLJI.cjs +0 -29
- package/dist/packem_shared/ensureFileSync-B7THM1sN.cjs +0 -29
- package/dist/packem_shared/ensureFileSync-BnhFBXaR.mjs +0 -27
- package/dist/packem_shared/ensureLink-ChsWDTK5.mjs +0 -34
- package/dist/packem_shared/ensureLink-CrxLNmHE.cjs +0 -36
- package/dist/packem_shared/ensureLinkSync-CG-DTUoV.mjs +0 -34
- package/dist/packem_shared/ensureLinkSync-D8uMqLh4.cjs +0 -36
- package/dist/packem_shared/ensureSymlink-BwJ_QhzJ.mjs +0 -52
- package/dist/packem_shared/ensureSymlink-D_ieOVYa.cjs +0 -54
- package/dist/packem_shared/ensureSymlinkSync-BamG29QK.mjs +0 -56
- package/dist/packem_shared/ensureSymlinkSync-DTMvUYZD.cjs +0 -58
- package/dist/packem_shared/findUp-D5W-MTpT.mjs +0 -63
- package/dist/packem_shared/findUp-DVIYN2wV.cjs +0 -65
- package/dist/packem_shared/findUpSync-BOiVyUOx.cjs +0 -65
- package/dist/packem_shared/findUpSync-DL3NPCYg.mjs +0 -63
- package/dist/packem_shared/get-file-info-type-BlryFnpp.cjs +0 -18
- package/dist/packem_shared/get-file-info-type-ButUVD6d.mjs +0 -16
- package/dist/packem_shared/index-BVZL6YMm.cjs +0 -110
- package/dist/packem_shared/index-r9Pk9gBe.mjs +0 -108
- package/dist/packem_shared/is-stats-identical-BfdEfO6i.cjs +0 -7
- package/dist/packem_shared/is-stats-identical-ByTYZ2Aw.mjs +0 -5
- package/dist/packem_shared/isAccessible-Bonsm1Ez.mjs +0 -20
- package/dist/packem_shared/isAccessible-ZNVGsSb7.cjs +0 -22
- package/dist/packem_shared/isAccessibleSync-3gnUWUwX.mjs +0 -20
- package/dist/packem_shared/isAccessibleSync-VWjQa-US.cjs +0 -22
- package/dist/packem_shared/move-DgF7Ul9L.mjs +0 -114
- package/dist/packem_shared/move-Dh925GL9.cjs +0 -121
- package/dist/packem_shared/parseJson-BA7Xrggq.mjs +0 -248
- package/dist/packem_shared/parseJson-LgPGI5ic.cjs +0 -250
- package/dist/packem_shared/readFile-b7UBVv17.mjs +0 -46
- package/dist/packem_shared/readFile-iFUhZHnh.cjs +0 -48
- package/dist/packem_shared/readFileSync-B3NTOR-W.cjs +0 -33
- package/dist/packem_shared/readFileSync-CkEJBqZB.mjs +0 -31
- package/dist/packem_shared/readJson-CEBHyuYq.cjs +0 -27
- package/dist/packem_shared/readJson-Ce9b06cu.mjs +0 -25
- package/dist/packem_shared/readJsonSync-B22hej0y.cjs +0 -27
- package/dist/packem_shared/readJsonSync-CkUI9_z5.mjs +0 -25
- package/dist/packem_shared/readYaml-C5MSs2GE.mjs +0 -13
- package/dist/packem_shared/readYaml-sR4bqUel.cjs +0 -15
- package/dist/packem_shared/readYamlSync-C3oOzxiN.cjs +0 -15
- package/dist/packem_shared/readYamlSync-CPjA-DLv.mjs +0 -13
- package/dist/packem_shared/remove-B2nxUObP.mjs +0 -18
- package/dist/packem_shared/remove-BpDiVPns.cjs +0 -20
- package/dist/packem_shared/removeSync-BosXW624.cjs +0 -20
- package/dist/packem_shared/removeSync-C87yepDI.mjs +0 -18
- package/dist/packem_shared/resolve-symlink-target-BbpEHdU2.mjs +0 -18
- package/dist/packem_shared/resolve-symlink-target-DImIddt6.cjs +0 -20
- package/dist/packem_shared/stripJsonComments-B66nRaTZ.mjs +0 -21
- package/dist/packem_shared/stripJsonComments-eDrcJvBT.cjs +0 -23
- package/dist/packem_shared/to-uint-8-array-B4CjMOD3.mjs +0 -21
- package/dist/packem_shared/to-uint-8-array-BaTEyX3D.cjs +0 -23
- package/dist/packem_shared/walk-CI3ygmrw.cjs +0 -100
- package/dist/packem_shared/walk-D7YA43g8.mjs +0 -98
- package/dist/packem_shared/walk-include-CMUSRa86.mjs +0 -20
- package/dist/packem_shared/walk-include-yUdRrF16.cjs +0 -23
- package/dist/packem_shared/walkSync-DLTsnwuJ.mjs +0 -103
- package/dist/packem_shared/walkSync-oXkmn9ZA.cjs +0 -105
- package/dist/packem_shared/writeFile-BZ4JBQxc.mjs +0 -58
- package/dist/packem_shared/writeFile-DgCFRCe5.cjs +0 -60
- package/dist/packem_shared/writeFileSync-Ctw5pNQH.mjs +0 -58
- package/dist/packem_shared/writeFileSync-DzXhx1pF.cjs +0 -60
- package/dist/packem_shared/writeJson-Bh4sU1Ly.cjs +0 -33
- package/dist/packem_shared/writeJson-axO_14yL.mjs +0 -31
- package/dist/packem_shared/writeJsonSync-CzngmuKb.mjs +0 -31
- package/dist/packem_shared/writeJsonSync-HFdHjunl.cjs +0 -33
- package/dist/packem_shared/writeYaml-3XQT2qtb.cjs +0 -29
- package/dist/packem_shared/writeYaml-BSFEuWp2.mjs +0 -27
- package/dist/packem_shared/writeYamlSync-B6VcXXIb.mjs +0 -27
- package/dist/packem_shared/writeYamlSync-BZR3If9v.cjs +0 -29
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const node_fs = require('node:fs');
|
|
4
|
-
const path = require('@visulima/path');
|
|
5
|
-
const utils = require('@visulima/path/utils');
|
|
6
|
-
const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs');
|
|
7
|
-
const ensureDirSync = require('./ensureDirSync-DHmWi3CF.cjs');
|
|
8
|
-
const getFileInfoType = require('./get-file-info-type-BlryFnpp.cjs');
|
|
9
|
-
const isStatsIdentical = require('./is-stats-identical-BfdEfO6i.cjs');
|
|
10
|
-
const resolveSymlinkTarget = require('./resolve-symlink-target-DImIddt6.cjs');
|
|
11
|
-
const AlreadyExistsError = require('./AlreadyExistsError-DpxtwQot.cjs');
|
|
12
|
-
|
|
13
|
-
var __defProp = Object.defineProperty;
|
|
14
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
-
const isWindows = process.platform === "win32" || /^(?:msys|cygwin)$/.test(process.env.OSTYPE);
|
|
16
|
-
const ensureSymlinkSync = /* @__PURE__ */ __name((target, linkName, type) => {
|
|
17
|
-
assertValidFileOrDirectoryPath(target);
|
|
18
|
-
assertValidFileOrDirectoryPath(linkName);
|
|
19
|
-
const targetRealPath = resolveSymlinkTarget.resolveSymlinkTarget(target, linkName);
|
|
20
|
-
linkName = path.toNamespacedPath(utils.toPath(linkName));
|
|
21
|
-
try {
|
|
22
|
-
const linkStatInfo = node_fs.lstatSync(linkName);
|
|
23
|
-
if (linkStatInfo.isSymbolicLink() && // eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
24
|
-
isStatsIdentical.isStatsIdentical(node_fs.statSync(targetRealPath), node_fs.statSync(linkName))) {
|
|
25
|
-
const sourceStat = node_fs.statSync(targetRealPath);
|
|
26
|
-
const destinationStat = node_fs.statSync(linkName);
|
|
27
|
-
if (isStatsIdentical.isStatsIdentical(sourceStat, destinationStat)) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
} catch {
|
|
32
|
-
}
|
|
33
|
-
const sourceStatInfo = node_fs.lstatSync(targetRealPath);
|
|
34
|
-
const sourceFilePathType = getFileInfoType.getFileInfoType(sourceStatInfo);
|
|
35
|
-
ensureDirSync(path.dirname(linkName));
|
|
36
|
-
const symlinkType = type ?? (isWindows ? "junction" : sourceFilePathType === "dir" ? "dir" : "file");
|
|
37
|
-
try {
|
|
38
|
-
node_fs.symlinkSync(path.toNamespacedPath(utils.toPath(targetRealPath)), linkName, symlinkType);
|
|
39
|
-
} catch (error) {
|
|
40
|
-
if (error.code !== "EEXIST") {
|
|
41
|
-
throw error;
|
|
42
|
-
}
|
|
43
|
-
const linkStatInfo = node_fs.lstatSync(linkName);
|
|
44
|
-
if (!linkStatInfo.isSymbolicLink()) {
|
|
45
|
-
throw new AlreadyExistsError("A " + getFileInfoType.getFileInfoType(linkStatInfo) + " already exists at the path: " + linkName);
|
|
46
|
-
}
|
|
47
|
-
const linkPath = node_fs.readlinkSync(linkName);
|
|
48
|
-
const linkRealPath = path.toNamespacedPath(path.resolve(linkPath));
|
|
49
|
-
if (linkRealPath !== targetRealPath) {
|
|
50
|
-
throw new AlreadyExistsError(
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
|
52
|
-
"A symlink targeting to an undesired path already exists: " + linkName + " -> " + linkRealPath
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}, "ensureSymlinkSync");
|
|
57
|
-
|
|
58
|
-
module.exports = ensureSymlinkSync;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { stat, lstat } from 'node:fs/promises';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import { resolve, parse, isAbsolute, dirname } from '@visulima/path';
|
|
4
|
-
import { toPath } from '@visulima/path/utils';
|
|
5
|
-
import { FIND_UP_STOP } from './F_OK-JER1LjUr.mjs';
|
|
6
|
-
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
const findUp = /* @__PURE__ */ __name(async (name, options = {}) => {
|
|
10
|
-
if (typeof name !== "string" && !Array.isArray(name) && typeof name !== "function") {
|
|
11
|
-
throw new TypeError("The `name` argument must be of type `string` or `string[]`");
|
|
12
|
-
}
|
|
13
|
-
const cwd = options.cwd ? toPath(options.cwd) : process.cwd();
|
|
14
|
-
let directory = resolve(cwd);
|
|
15
|
-
const { root } = parse(directory);
|
|
16
|
-
const stopPath = toPath(options.stopAt ?? root);
|
|
17
|
-
const stopAt = resolve(directory, stopPath);
|
|
18
|
-
const type = options.type ?? "file";
|
|
19
|
-
const getMatchers = /* @__PURE__ */ __name(async function(currentDirectory) {
|
|
20
|
-
if (typeof name === "function") {
|
|
21
|
-
const match = await name(currentDirectory);
|
|
22
|
-
return [match];
|
|
23
|
-
}
|
|
24
|
-
if (typeof name === "string") {
|
|
25
|
-
return [name];
|
|
26
|
-
}
|
|
27
|
-
if (Array.isArray(name)) {
|
|
28
|
-
return name;
|
|
29
|
-
}
|
|
30
|
-
return [name];
|
|
31
|
-
}, "getMatchers");
|
|
32
|
-
if (options.allowSymlinks === void 0) {
|
|
33
|
-
options.allowSymlinks = true;
|
|
34
|
-
}
|
|
35
|
-
const statFunction = options.allowSymlinks ? stat : lstat;
|
|
36
|
-
while (directory && directory !== stopAt && directory !== root) {
|
|
37
|
-
for await (let fileName of await getMatchers(directory)) {
|
|
38
|
-
if (fileName === FIND_UP_STOP) {
|
|
39
|
-
return void 0;
|
|
40
|
-
}
|
|
41
|
-
if (fileName === void 0) {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
if (Buffer.isBuffer(fileName)) {
|
|
45
|
-
fileName = fileName.toString();
|
|
46
|
-
} else if (fileName instanceof URL) {
|
|
47
|
-
fileName = fileURLToPath(fileName);
|
|
48
|
-
}
|
|
49
|
-
const filePath = isAbsolute(fileName) ? fileName : resolve(directory, fileName);
|
|
50
|
-
try {
|
|
51
|
-
const stats = await statFunction(filePath);
|
|
52
|
-
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) {
|
|
53
|
-
return filePath;
|
|
54
|
-
}
|
|
55
|
-
} catch {
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
directory = dirname(directory);
|
|
59
|
-
}
|
|
60
|
-
return void 0;
|
|
61
|
-
}, "findUp");
|
|
62
|
-
|
|
63
|
-
export { findUp as default };
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const promises = require('node:fs/promises');
|
|
4
|
-
const node_url = require('node:url');
|
|
5
|
-
const path = require('@visulima/path');
|
|
6
|
-
const utils = require('@visulima/path/utils');
|
|
7
|
-
const F_OK = require('./F_OK-CWSqQIdF.cjs');
|
|
8
|
-
|
|
9
|
-
var __defProp = Object.defineProperty;
|
|
10
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
11
|
-
const findUp = /* @__PURE__ */ __name(async (name, options = {}) => {
|
|
12
|
-
if (typeof name !== "string" && !Array.isArray(name) && typeof name !== "function") {
|
|
13
|
-
throw new TypeError("The `name` argument must be of type `string` or `string[]`");
|
|
14
|
-
}
|
|
15
|
-
const cwd = options.cwd ? utils.toPath(options.cwd) : process.cwd();
|
|
16
|
-
let directory = path.resolve(cwd);
|
|
17
|
-
const { root } = path.parse(directory);
|
|
18
|
-
const stopPath = utils.toPath(options.stopAt ?? root);
|
|
19
|
-
const stopAt = path.resolve(directory, stopPath);
|
|
20
|
-
const type = options.type ?? "file";
|
|
21
|
-
const getMatchers = /* @__PURE__ */ __name(async function(currentDirectory) {
|
|
22
|
-
if (typeof name === "function") {
|
|
23
|
-
const match = await name(currentDirectory);
|
|
24
|
-
return [match];
|
|
25
|
-
}
|
|
26
|
-
if (typeof name === "string") {
|
|
27
|
-
return [name];
|
|
28
|
-
}
|
|
29
|
-
if (Array.isArray(name)) {
|
|
30
|
-
return name;
|
|
31
|
-
}
|
|
32
|
-
return [name];
|
|
33
|
-
}, "getMatchers");
|
|
34
|
-
if (options.allowSymlinks === void 0) {
|
|
35
|
-
options.allowSymlinks = true;
|
|
36
|
-
}
|
|
37
|
-
const statFunction = options.allowSymlinks ? promises.stat : promises.lstat;
|
|
38
|
-
while (directory && directory !== stopAt && directory !== root) {
|
|
39
|
-
for await (let fileName of await getMatchers(directory)) {
|
|
40
|
-
if (fileName === F_OK.FIND_UP_STOP) {
|
|
41
|
-
return void 0;
|
|
42
|
-
}
|
|
43
|
-
if (fileName === void 0) {
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
if (Buffer.isBuffer(fileName)) {
|
|
47
|
-
fileName = fileName.toString();
|
|
48
|
-
} else if (fileName instanceof URL) {
|
|
49
|
-
fileName = node_url.fileURLToPath(fileName);
|
|
50
|
-
}
|
|
51
|
-
const filePath = path.isAbsolute(fileName) ? fileName : path.resolve(directory, fileName);
|
|
52
|
-
try {
|
|
53
|
-
const stats = await statFunction(filePath);
|
|
54
|
-
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) {
|
|
55
|
-
return filePath;
|
|
56
|
-
}
|
|
57
|
-
} catch {
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
directory = path.dirname(directory);
|
|
61
|
-
}
|
|
62
|
-
return void 0;
|
|
63
|
-
}, "findUp");
|
|
64
|
-
|
|
65
|
-
module.exports = findUp;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const node_fs = require('node:fs');
|
|
4
|
-
const node_url = require('node:url');
|
|
5
|
-
const path = require('@visulima/path');
|
|
6
|
-
const utils = require('@visulima/path/utils');
|
|
7
|
-
const F_OK = require('./F_OK-CWSqQIdF.cjs');
|
|
8
|
-
|
|
9
|
-
var __defProp = Object.defineProperty;
|
|
10
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
11
|
-
const findUpSync = /* @__PURE__ */ __name((name, options = {}) => {
|
|
12
|
-
if (typeof name !== "string" && !Array.isArray(name) && typeof name !== "function") {
|
|
13
|
-
throw new TypeError("The `name` argument must be of type `string` or `string[]`");
|
|
14
|
-
}
|
|
15
|
-
const cwd = options.cwd ? utils.toPath(options.cwd) : process.cwd();
|
|
16
|
-
let directory = path.resolve(cwd);
|
|
17
|
-
const { root } = path.parse(directory);
|
|
18
|
-
const stopPath = utils.toPath(options.stopAt ?? root);
|
|
19
|
-
const stopAt = path.resolve(directory, stopPath);
|
|
20
|
-
const type = options.type ?? "file";
|
|
21
|
-
const getMatchers = /* @__PURE__ */ __name(function(currentDirectory) {
|
|
22
|
-
if (typeof name === "function") {
|
|
23
|
-
const match = name(currentDirectory);
|
|
24
|
-
return [match];
|
|
25
|
-
}
|
|
26
|
-
if (typeof name === "string") {
|
|
27
|
-
return [name];
|
|
28
|
-
}
|
|
29
|
-
if (Array.isArray(name)) {
|
|
30
|
-
return name;
|
|
31
|
-
}
|
|
32
|
-
return [name];
|
|
33
|
-
}, "getMatchers");
|
|
34
|
-
if (options.allowSymlinks === void 0) {
|
|
35
|
-
options.allowSymlinks = true;
|
|
36
|
-
}
|
|
37
|
-
const statFunction = options.allowSymlinks ? node_fs.statSync : node_fs.lstatSync;
|
|
38
|
-
while (directory && directory !== stopAt && directory !== root) {
|
|
39
|
-
for (let fileName of getMatchers(directory)) {
|
|
40
|
-
if (fileName === F_OK.FIND_UP_STOP) {
|
|
41
|
-
return void 0;
|
|
42
|
-
}
|
|
43
|
-
if (fileName === void 0) {
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
if (Buffer.isBuffer(fileName)) {
|
|
47
|
-
fileName = fileName.toString();
|
|
48
|
-
} else if (fileName instanceof URL) {
|
|
49
|
-
fileName = node_url.fileURLToPath(fileName);
|
|
50
|
-
}
|
|
51
|
-
const filePath = path.isAbsolute(fileName) ? fileName : path.resolve(directory, fileName);
|
|
52
|
-
try {
|
|
53
|
-
const stats = statFunction(filePath);
|
|
54
|
-
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) {
|
|
55
|
-
return filePath;
|
|
56
|
-
}
|
|
57
|
-
} catch {
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
directory = path.dirname(directory);
|
|
61
|
-
}
|
|
62
|
-
return void 0;
|
|
63
|
-
}, "findUpSync");
|
|
64
|
-
|
|
65
|
-
module.exports = findUpSync;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { statSync, lstatSync } from 'node:fs';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import { resolve, parse, isAbsolute, dirname } from '@visulima/path';
|
|
4
|
-
import { toPath } from '@visulima/path/utils';
|
|
5
|
-
import { FIND_UP_STOP } from './F_OK-JER1LjUr.mjs';
|
|
6
|
-
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
const findUpSync = /* @__PURE__ */ __name((name, options = {}) => {
|
|
10
|
-
if (typeof name !== "string" && !Array.isArray(name) && typeof name !== "function") {
|
|
11
|
-
throw new TypeError("The `name` argument must be of type `string` or `string[]`");
|
|
12
|
-
}
|
|
13
|
-
const cwd = options.cwd ? toPath(options.cwd) : process.cwd();
|
|
14
|
-
let directory = resolve(cwd);
|
|
15
|
-
const { root } = parse(directory);
|
|
16
|
-
const stopPath = toPath(options.stopAt ?? root);
|
|
17
|
-
const stopAt = resolve(directory, stopPath);
|
|
18
|
-
const type = options.type ?? "file";
|
|
19
|
-
const getMatchers = /* @__PURE__ */ __name(function(currentDirectory) {
|
|
20
|
-
if (typeof name === "function") {
|
|
21
|
-
const match = name(currentDirectory);
|
|
22
|
-
return [match];
|
|
23
|
-
}
|
|
24
|
-
if (typeof name === "string") {
|
|
25
|
-
return [name];
|
|
26
|
-
}
|
|
27
|
-
if (Array.isArray(name)) {
|
|
28
|
-
return name;
|
|
29
|
-
}
|
|
30
|
-
return [name];
|
|
31
|
-
}, "getMatchers");
|
|
32
|
-
if (options.allowSymlinks === void 0) {
|
|
33
|
-
options.allowSymlinks = true;
|
|
34
|
-
}
|
|
35
|
-
const statFunction = options.allowSymlinks ? statSync : lstatSync;
|
|
36
|
-
while (directory && directory !== stopAt && directory !== root) {
|
|
37
|
-
for (let fileName of getMatchers(directory)) {
|
|
38
|
-
if (fileName === FIND_UP_STOP) {
|
|
39
|
-
return void 0;
|
|
40
|
-
}
|
|
41
|
-
if (fileName === void 0) {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
if (Buffer.isBuffer(fileName)) {
|
|
45
|
-
fileName = fileName.toString();
|
|
46
|
-
} else if (fileName instanceof URL) {
|
|
47
|
-
fileName = fileURLToPath(fileName);
|
|
48
|
-
}
|
|
49
|
-
const filePath = isAbsolute(fileName) ? fileName : resolve(directory, fileName);
|
|
50
|
-
try {
|
|
51
|
-
const stats = statFunction(filePath);
|
|
52
|
-
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) {
|
|
53
|
-
return filePath;
|
|
54
|
-
}
|
|
55
|
-
} catch {
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
directory = dirname(directory);
|
|
59
|
-
}
|
|
60
|
-
return void 0;
|
|
61
|
-
}, "findUpSync");
|
|
62
|
-
|
|
63
|
-
export { findUpSync as default };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
-
const getFileInfoType = /* @__PURE__ */ __name((fileInfo) => {
|
|
6
|
-
if (fileInfo.isFile()) {
|
|
7
|
-
return "file";
|
|
8
|
-
}
|
|
9
|
-
if (fileInfo.isDirectory()) {
|
|
10
|
-
return "dir";
|
|
11
|
-
}
|
|
12
|
-
if (fileInfo.isSymbolicLink()) {
|
|
13
|
-
return "symlink";
|
|
14
|
-
}
|
|
15
|
-
return void 0;
|
|
16
|
-
}, "getFileInfoType");
|
|
17
|
-
|
|
18
|
-
exports.getFileInfoType = getFileInfoType;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
const getFileInfoType = /* @__PURE__ */ __name((fileInfo) => {
|
|
4
|
-
if (fileInfo.isFile()) {
|
|
5
|
-
return "file";
|
|
6
|
-
}
|
|
7
|
-
if (fileInfo.isDirectory()) {
|
|
8
|
-
return "dir";
|
|
9
|
-
}
|
|
10
|
-
if (fileInfo.isSymbolicLink()) {
|
|
11
|
-
return "symlink";
|
|
12
|
-
}
|
|
13
|
-
return void 0;
|
|
14
|
-
}, "getFileInfoType");
|
|
15
|
-
|
|
16
|
-
export { getFileInfoType as g };
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
-
const INDENT_REGEX = /^(?:( )+|\t+)/;
|
|
6
|
-
const INDENT_TYPE_SPACE = "space";
|
|
7
|
-
const INDENT_TYPE_TAB = "tab";
|
|
8
|
-
function makeIndentsMap(string, ignoreSingleSpaces) {
|
|
9
|
-
const indents = /* @__PURE__ */ new Map();
|
|
10
|
-
let previousSize = 0;
|
|
11
|
-
let previousIndentType;
|
|
12
|
-
let key;
|
|
13
|
-
for (const line of string.split(/\n/g)) {
|
|
14
|
-
if (!line) {
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
let indent;
|
|
18
|
-
let indentType;
|
|
19
|
-
let use;
|
|
20
|
-
let weight;
|
|
21
|
-
let entry;
|
|
22
|
-
const matches = line.match(INDENT_REGEX);
|
|
23
|
-
if (matches === null) {
|
|
24
|
-
previousSize = 0;
|
|
25
|
-
previousIndentType = "";
|
|
26
|
-
} else {
|
|
27
|
-
indent = matches[0].length;
|
|
28
|
-
indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
|
|
29
|
-
if (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (indentType !== previousIndentType) {
|
|
33
|
-
previousSize = 0;
|
|
34
|
-
}
|
|
35
|
-
previousIndentType = indentType;
|
|
36
|
-
use = 1;
|
|
37
|
-
weight = 0;
|
|
38
|
-
const indentDifference = indent - previousSize;
|
|
39
|
-
previousSize = indent;
|
|
40
|
-
if (indentDifference === 0) {
|
|
41
|
-
use = 0;
|
|
42
|
-
weight = 1;
|
|
43
|
-
} else {
|
|
44
|
-
const absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;
|
|
45
|
-
key = encodeIndentsKey(indentType, absoluteIndentDifference);
|
|
46
|
-
}
|
|
47
|
-
entry = indents.get(key);
|
|
48
|
-
entry = entry === void 0 ? [1, 0] : [entry[0] + use, entry[1] + weight];
|
|
49
|
-
indents.set(key, entry);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return indents;
|
|
53
|
-
}
|
|
54
|
-
__name(makeIndentsMap, "makeIndentsMap");
|
|
55
|
-
function encodeIndentsKey(indentType, indentAmount) {
|
|
56
|
-
const typeCharacter = indentType === INDENT_TYPE_SPACE ? "s" : "t";
|
|
57
|
-
return typeCharacter + String(indentAmount);
|
|
58
|
-
}
|
|
59
|
-
__name(encodeIndentsKey, "encodeIndentsKey");
|
|
60
|
-
function decodeIndentsKey(indentsKey) {
|
|
61
|
-
const keyHasTypeSpace = indentsKey[0] === "s";
|
|
62
|
-
const type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
|
|
63
|
-
const amount = Number(indentsKey.slice(1));
|
|
64
|
-
return { type, amount };
|
|
65
|
-
}
|
|
66
|
-
__name(decodeIndentsKey, "decodeIndentsKey");
|
|
67
|
-
function getMostUsedKey(indents) {
|
|
68
|
-
let result;
|
|
69
|
-
let maxUsed = 0;
|
|
70
|
-
let maxWeight = 0;
|
|
71
|
-
for (const [key, [usedCount, weight]] of indents) {
|
|
72
|
-
if (usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) {
|
|
73
|
-
maxUsed = usedCount;
|
|
74
|
-
maxWeight = weight;
|
|
75
|
-
result = key;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return result;
|
|
79
|
-
}
|
|
80
|
-
__name(getMostUsedKey, "getMostUsedKey");
|
|
81
|
-
function makeIndentString(type, amount) {
|
|
82
|
-
const indentCharacter = type === INDENT_TYPE_SPACE ? " " : " ";
|
|
83
|
-
return indentCharacter.repeat(amount);
|
|
84
|
-
}
|
|
85
|
-
__name(makeIndentString, "makeIndentString");
|
|
86
|
-
function detectIndent(string) {
|
|
87
|
-
if (typeof string !== "string") {
|
|
88
|
-
throw new TypeError("Expected a string");
|
|
89
|
-
}
|
|
90
|
-
let indents = makeIndentsMap(string, true);
|
|
91
|
-
if (indents.size === 0) {
|
|
92
|
-
indents = makeIndentsMap(string, false);
|
|
93
|
-
}
|
|
94
|
-
const keyOfMostUsedIndent = getMostUsedKey(indents);
|
|
95
|
-
let type;
|
|
96
|
-
let amount = 0;
|
|
97
|
-
let indent = "";
|
|
98
|
-
if (keyOfMostUsedIndent !== void 0) {
|
|
99
|
-
({ type, amount } = decodeIndentsKey(keyOfMostUsedIndent));
|
|
100
|
-
indent = makeIndentString(type, amount);
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
amount,
|
|
104
|
-
type,
|
|
105
|
-
indent
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
__name(detectIndent, "detectIndent");
|
|
109
|
-
|
|
110
|
-
exports.detectIndent = detectIndent;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
const INDENT_REGEX = /^(?:( )+|\t+)/;
|
|
4
|
-
const INDENT_TYPE_SPACE = "space";
|
|
5
|
-
const INDENT_TYPE_TAB = "tab";
|
|
6
|
-
function makeIndentsMap(string, ignoreSingleSpaces) {
|
|
7
|
-
const indents = /* @__PURE__ */ new Map();
|
|
8
|
-
let previousSize = 0;
|
|
9
|
-
let previousIndentType;
|
|
10
|
-
let key;
|
|
11
|
-
for (const line of string.split(/\n/g)) {
|
|
12
|
-
if (!line) {
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
let indent;
|
|
16
|
-
let indentType;
|
|
17
|
-
let use;
|
|
18
|
-
let weight;
|
|
19
|
-
let entry;
|
|
20
|
-
const matches = line.match(INDENT_REGEX);
|
|
21
|
-
if (matches === null) {
|
|
22
|
-
previousSize = 0;
|
|
23
|
-
previousIndentType = "";
|
|
24
|
-
} else {
|
|
25
|
-
indent = matches[0].length;
|
|
26
|
-
indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
|
|
27
|
-
if (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (indentType !== previousIndentType) {
|
|
31
|
-
previousSize = 0;
|
|
32
|
-
}
|
|
33
|
-
previousIndentType = indentType;
|
|
34
|
-
use = 1;
|
|
35
|
-
weight = 0;
|
|
36
|
-
const indentDifference = indent - previousSize;
|
|
37
|
-
previousSize = indent;
|
|
38
|
-
if (indentDifference === 0) {
|
|
39
|
-
use = 0;
|
|
40
|
-
weight = 1;
|
|
41
|
-
} else {
|
|
42
|
-
const absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;
|
|
43
|
-
key = encodeIndentsKey(indentType, absoluteIndentDifference);
|
|
44
|
-
}
|
|
45
|
-
entry = indents.get(key);
|
|
46
|
-
entry = entry === void 0 ? [1, 0] : [entry[0] + use, entry[1] + weight];
|
|
47
|
-
indents.set(key, entry);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return indents;
|
|
51
|
-
}
|
|
52
|
-
__name(makeIndentsMap, "makeIndentsMap");
|
|
53
|
-
function encodeIndentsKey(indentType, indentAmount) {
|
|
54
|
-
const typeCharacter = indentType === INDENT_TYPE_SPACE ? "s" : "t";
|
|
55
|
-
return typeCharacter + String(indentAmount);
|
|
56
|
-
}
|
|
57
|
-
__name(encodeIndentsKey, "encodeIndentsKey");
|
|
58
|
-
function decodeIndentsKey(indentsKey) {
|
|
59
|
-
const keyHasTypeSpace = indentsKey[0] === "s";
|
|
60
|
-
const type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
|
|
61
|
-
const amount = Number(indentsKey.slice(1));
|
|
62
|
-
return { type, amount };
|
|
63
|
-
}
|
|
64
|
-
__name(decodeIndentsKey, "decodeIndentsKey");
|
|
65
|
-
function getMostUsedKey(indents) {
|
|
66
|
-
let result;
|
|
67
|
-
let maxUsed = 0;
|
|
68
|
-
let maxWeight = 0;
|
|
69
|
-
for (const [key, [usedCount, weight]] of indents) {
|
|
70
|
-
if (usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) {
|
|
71
|
-
maxUsed = usedCount;
|
|
72
|
-
maxWeight = weight;
|
|
73
|
-
result = key;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return result;
|
|
77
|
-
}
|
|
78
|
-
__name(getMostUsedKey, "getMostUsedKey");
|
|
79
|
-
function makeIndentString(type, amount) {
|
|
80
|
-
const indentCharacter = type === INDENT_TYPE_SPACE ? " " : " ";
|
|
81
|
-
return indentCharacter.repeat(amount);
|
|
82
|
-
}
|
|
83
|
-
__name(makeIndentString, "makeIndentString");
|
|
84
|
-
function detectIndent(string) {
|
|
85
|
-
if (typeof string !== "string") {
|
|
86
|
-
throw new TypeError("Expected a string");
|
|
87
|
-
}
|
|
88
|
-
let indents = makeIndentsMap(string, true);
|
|
89
|
-
if (indents.size === 0) {
|
|
90
|
-
indents = makeIndentsMap(string, false);
|
|
91
|
-
}
|
|
92
|
-
const keyOfMostUsedIndent = getMostUsedKey(indents);
|
|
93
|
-
let type;
|
|
94
|
-
let amount = 0;
|
|
95
|
-
let indent = "";
|
|
96
|
-
if (keyOfMostUsedIndent !== void 0) {
|
|
97
|
-
({ type, amount } = decodeIndentsKey(keyOfMostUsedIndent));
|
|
98
|
-
indent = makeIndentString(type, amount);
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
amount,
|
|
102
|
-
type,
|
|
103
|
-
indent
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
__name(detectIndent, "detectIndent");
|
|
107
|
-
|
|
108
|
-
export { detectIndent as d };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
-
const isStatsIdentical = /* @__PURE__ */ __name((sourceStat, destinationStat) => !!destinationStat.ino && !!destinationStat.dev && destinationStat.ino === sourceStat.ino && destinationStat.dev === sourceStat.dev, "isStatsIdentical");
|
|
6
|
-
|
|
7
|
-
exports.isStatsIdentical = isStatsIdentical;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
const isStatsIdentical = /* @__PURE__ */ __name((sourceStat, destinationStat) => !!destinationStat.ino && !!destinationStat.dev && destinationStat.ino === sourceStat.ino && destinationStat.dev === sourceStat.dev, "isStatsIdentical");
|
|
4
|
-
|
|
5
|
-
export { isStatsIdentical as i };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { access } from 'node:fs/promises';
|
|
2
|
-
import { toPath } from '@visulima/path/utils';
|
|
3
|
-
import { F_OK } from './F_OK-JER1LjUr.mjs';
|
|
4
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
|
|
5
|
-
|
|
6
|
-
var __defProp = Object.defineProperty;
|
|
7
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
-
async function isAccessible(path, mode = F_OK) {
|
|
9
|
-
assertValidFileOrDirectoryPath(path);
|
|
10
|
-
path = toPath(path);
|
|
11
|
-
try {
|
|
12
|
-
await access(path, mode);
|
|
13
|
-
return true;
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
__name(isAccessible, "isAccessible");
|
|
19
|
-
|
|
20
|
-
export { isAccessible as default };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const promises = require('node:fs/promises');
|
|
4
|
-
const utils = require('@visulima/path/utils');
|
|
5
|
-
const F_OK = require('./F_OK-CWSqQIdF.cjs');
|
|
6
|
-
const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs');
|
|
7
|
-
|
|
8
|
-
var __defProp = Object.defineProperty;
|
|
9
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
-
async function isAccessible(path, mode = F_OK.F_OK) {
|
|
11
|
-
assertValidFileOrDirectoryPath(path);
|
|
12
|
-
path = utils.toPath(path);
|
|
13
|
-
try {
|
|
14
|
-
await promises.access(path, mode);
|
|
15
|
-
return true;
|
|
16
|
-
} catch {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
__name(isAccessible, "isAccessible");
|
|
21
|
-
|
|
22
|
-
module.exports = isAccessible;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { accessSync } from 'node:fs';
|
|
2
|
-
import { toPath } from '@visulima/path/utils';
|
|
3
|
-
import { F_OK } from './F_OK-JER1LjUr.mjs';
|
|
4
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
|
|
5
|
-
|
|
6
|
-
var __defProp = Object.defineProperty;
|
|
7
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
-
function isAccessibleSync(path, mode = F_OK) {
|
|
9
|
-
assertValidFileOrDirectoryPath(path);
|
|
10
|
-
path = toPath(path);
|
|
11
|
-
try {
|
|
12
|
-
accessSync(path, mode);
|
|
13
|
-
return true;
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
__name(isAccessibleSync, "isAccessibleSync");
|
|
19
|
-
|
|
20
|
-
export { isAccessibleSync as default };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const node_fs = require('node:fs');
|
|
4
|
-
const utils = require('@visulima/path/utils');
|
|
5
|
-
const F_OK = require('./F_OK-CWSqQIdF.cjs');
|
|
6
|
-
const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs');
|
|
7
|
-
|
|
8
|
-
var __defProp = Object.defineProperty;
|
|
9
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
-
function isAccessibleSync(path, mode = F_OK.F_OK) {
|
|
11
|
-
assertValidFileOrDirectoryPath(path);
|
|
12
|
-
path = utils.toPath(path);
|
|
13
|
-
try {
|
|
14
|
-
node_fs.accessSync(path, mode);
|
|
15
|
-
return true;
|
|
16
|
-
} catch {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
__name(isAccessibleSync, "isAccessibleSync");
|
|
21
|
-
|
|
22
|
-
module.exports = isAccessibleSync;
|