@visulima/fs 2.3.5 → 2.3.7
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 +20 -0
- package/README.md +318 -362
- package/dist/error.cjs +21 -1
- package/dist/error.mjs +7 -1
- package/dist/index.cjs +88 -1
- package/dist/index.mjs +35 -1
- package/dist/packem_shared/AlreadyExistsError-DpxtwQot.cjs +34 -0
- package/dist/packem_shared/AlreadyExistsError-GK7J9fVA.mjs +32 -0
- package/dist/packem_shared/DirectoryError-D8FHcAqu.cjs +34 -0
- package/dist/packem_shared/DirectoryError-DByTWE7t.mjs +32 -0
- package/dist/packem_shared/F_OK-CWSqQIdF.cjs +17 -0
- package/dist/packem_shared/F_OK-JER1LjUr.mjs +8 -0
- package/dist/packem_shared/JSONError-BCIIHvzq.mjs +28 -0
- package/dist/packem_shared/JSONError-gkXvBSar.cjs +30 -0
- package/dist/packem_shared/LF-CU3KsvZC.mjs +20 -0
- package/dist/packem_shared/LF-bB2qO80j.cjs +28 -0
- package/dist/packem_shared/NotEmptyError-BCS_5pPt.cjs +34 -0
- package/dist/packem_shared/NotEmptyError-DCXooh5l.mjs +32 -0
- package/dist/packem_shared/NotFoundError-B_1nPl3K.cjs +34 -0
- package/dist/packem_shared/NotFoundError-CUdcC61I.mjs +32 -0
- package/dist/packem_shared/PermissionError-CqGMI9qC.mjs +32 -0
- package/dist/packem_shared/PermissionError-QFMKgk2l.cjs +34 -0
- package/dist/packem_shared/WalkError-B7_AVs7d.cjs +27 -0
- package/dist/packem_shared/WalkError-H9EuRv7O.mjs +25 -0
- package/dist/packem_shared/assertValidFileContents-CRVvyM6b.cjs +11 -0
- package/dist/packem_shared/assertValidFileContents-Ox-ScfeK.mjs +9 -0
- package/dist/packem_shared/assertValidFileOrDirectoryPath-BMbgA-eI.cjs +11 -0
- package/dist/packem_shared/assertValidFileOrDirectoryPath-BWWgA1wj.mjs +9 -0
- package/dist/packem_shared/collect-BtDVJEOm.mjs +16 -0
- package/dist/packem_shared/collect-DxUriHCH.cjs +18 -0
- package/dist/packem_shared/collectSync-BaA0s001.cjs +18 -0
- package/dist/packem_shared/collectSync-CGjdb50I.mjs +16 -0
- package/dist/packem_shared/emptyDir-DcCfiNcf.cjs +22 -0
- package/dist/packem_shared/emptyDir-Dw5xSBox.mjs +20 -0
- package/dist/packem_shared/emptyDirSync-BoknkGUe.cjs +21 -0
- package/dist/packem_shared/emptyDirSync-DTGPXQ3v.mjs +19 -0
- package/dist/packem_shared/ensureDir-XiBlkOLR.mjs +33 -0
- package/dist/packem_shared/ensureDir-iUK2ga5M.cjs +35 -0
- package/dist/packem_shared/ensureDirSync-2IFUHFK2.mjs +33 -0
- package/dist/packem_shared/ensureDirSync-CXdMkg0Y.cjs +35 -0
- package/dist/packem_shared/ensureFile-Br8tFUJ7.cjs +29 -0
- package/dist/packem_shared/ensureFile-C2bWlBEa.mjs +27 -0
- package/dist/packem_shared/ensureFileSync-CZzSkNGC.cjs +29 -0
- package/dist/packem_shared/ensureFileSync-DkFfhOEs.mjs +27 -0
- package/dist/packem_shared/ensureLink-CFiabAD3.mjs +34 -0
- package/dist/packem_shared/ensureLink-Dqw5GBDq.cjs +36 -0
- package/dist/packem_shared/ensureLinkSync-BVw3h6sK.cjs +36 -0
- package/dist/packem_shared/ensureLinkSync-Dk-YeRg6.mjs +34 -0
- package/dist/packem_shared/ensureSymlink-CFSfreco.cjs +54 -0
- package/dist/packem_shared/ensureSymlink-CSqngPoI.mjs +52 -0
- package/dist/packem_shared/ensureSymlinkSync-BCd9bzsx.cjs +58 -0
- package/dist/packem_shared/ensureSymlinkSync-QRaNZX2E.mjs +56 -0
- package/dist/packem_shared/findUp-C8_QpAtD.mjs +63 -0
- package/dist/packem_shared/findUp-DA511Swp.cjs +65 -0
- package/dist/packem_shared/findUpSync-DVOd3V-q.mjs +63 -0
- package/dist/packem_shared/findUpSync-u1rGibzw.cjs +65 -0
- package/dist/packem_shared/get-file-info-type-BpRzQHvd.cjs +18 -0
- package/dist/packem_shared/get-file-info-type-CeiZ6n6g.mjs +16 -0
- package/dist/packem_shared/index-ajT9ecry.mjs +108 -0
- package/dist/packem_shared/index-ngvEMjBI.cjs +110 -0
- package/dist/packem_shared/is-stats-identical-BfdEfO6i.cjs +7 -0
- package/dist/packem_shared/is-stats-identical-ByTYZ2Aw.mjs +5 -0
- package/dist/packem_shared/isAccessible-Bonsm1Ez.mjs +20 -0
- package/dist/packem_shared/isAccessible-ZNVGsSb7.cjs +22 -0
- package/dist/packem_shared/isAccessibleSync-3gnUWUwX.mjs +20 -0
- package/dist/packem_shared/isAccessibleSync-VWjQa-US.cjs +22 -0
- package/dist/packem_shared/move-DgF7Ul9L.mjs +114 -0
- package/dist/packem_shared/move-Dh925GL9.cjs +121 -0
- package/dist/packem_shared/parseJson-DcUo4Rpt.cjs +251 -0
- package/dist/packem_shared/parseJson-n9THWOFI.mjs +249 -0
- package/dist/packem_shared/readFile-DUM-xNoB.mjs +46 -0
- package/dist/packem_shared/readFile-iFUhZHnh.cjs +48 -0
- package/dist/packem_shared/readFileSync-B3NTOR-W.cjs +33 -0
- package/dist/packem_shared/readFileSync-Cck96_o0.mjs +31 -0
- package/dist/packem_shared/readJson-DIHRleEE.mjs +25 -0
- package/dist/packem_shared/readJson-JrCHMN3m.cjs +27 -0
- package/dist/packem_shared/readJsonSync-BPfxTuQL.mjs +25 -0
- package/dist/packem_shared/readJsonSync-o_MAOlUv.cjs +27 -0
- package/dist/packem_shared/readYaml-sR4bqUel.cjs +15 -0
- package/dist/packem_shared/readYaml-vVKK8ZzY.mjs +13 -0
- package/dist/packem_shared/readYamlSync-C3oOzxiN.cjs +15 -0
- package/dist/packem_shared/readYamlSync-MOLH4gXB.mjs +13 -0
- package/dist/packem_shared/remove-B2nxUObP.mjs +18 -0
- package/dist/packem_shared/remove-BpDiVPns.cjs +20 -0
- package/dist/packem_shared/removeSync-BosXW624.cjs +20 -0
- package/dist/packem_shared/removeSync-C87yepDI.mjs +18 -0
- package/dist/packem_shared/resolve-symlink-target-BbpEHdU2.mjs +18 -0
- package/dist/packem_shared/resolve-symlink-target-DImIddt6.cjs +20 -0
- package/dist/packem_shared/stripJsonComments-B66nRaTZ.mjs +21 -0
- package/dist/packem_shared/stripJsonComments-eDrcJvBT.cjs +23 -0
- package/dist/packem_shared/to-uint-8-array-B4CjMOD3.mjs +21 -0
- package/dist/packem_shared/to-uint-8-array-BaTEyX3D.cjs +23 -0
- package/dist/packem_shared/walk-BW7b4GXI.cjs +106 -0
- package/dist/packem_shared/walk-CNcSYQVq.mjs +104 -0
- package/dist/packem_shared/walk-include-CMUSRa86.mjs +20 -0
- package/dist/packem_shared/walk-include-yUdRrF16.cjs +23 -0
- package/dist/packem_shared/walkSync-BzxdFWLU.mjs +103 -0
- package/dist/packem_shared/walkSync-DgPj93NL.cjs +105 -0
- package/dist/packem_shared/writeFile-B7dhfseN.mjs +58 -0
- package/dist/packem_shared/writeFile-DKu5-M8x.cjs +60 -0
- package/dist/packem_shared/writeFileSync-Db6pmY0q.cjs +60 -0
- package/dist/packem_shared/writeFileSync-mMGYqOc8.mjs +58 -0
- package/dist/packem_shared/writeJson-BSQE2uFN.mjs +31 -0
- package/dist/packem_shared/writeJson-DtnnjTix.cjs +33 -0
- package/dist/packem_shared/writeJsonSync-C_i6LsGT.mjs +31 -0
- package/dist/packem_shared/writeJsonSync-Dz5-B2PD.cjs +33 -0
- package/dist/packem_shared/writeYaml-B-KoZN0E.cjs +14 -0
- package/dist/packem_shared/writeYaml-DSTzKc0_.mjs +12 -0
- package/dist/packem_shared/writeYamlSync-D6borSP1.cjs +14 -0
- package/dist/packem_shared/writeYamlSync-agxYIea0.mjs +12 -0
- package/dist/utils.cjs +19 -1
- package/dist/utils.mjs +6 -1
- package/package.json +15 -16
- package/dist/packem_shared/AlreadyExistsError-CEu6_Tjb.mjs +0 -1
- package/dist/packem_shared/AlreadyExistsError-GC2XUgzJ.cjs +0 -1
- package/dist/packem_shared/DirectoryError-B8wqer68.cjs +0 -1
- package/dist/packem_shared/DirectoryError-ddlbUV8C.mjs +0 -1
- package/dist/packem_shared/F_OK-6WAweffB.cjs +0 -1
- package/dist/packem_shared/F_OK-B71i3mUa.mjs +0 -1
- package/dist/packem_shared/JSONError-CVkb3xZ3.mjs +0 -4
- package/dist/packem_shared/JSONError-CWuiGmNc.cjs +0 -4
- package/dist/packem_shared/LF-D4BqIfQm.cjs +0 -3
- package/dist/packem_shared/LF-Dbx0i6a7.mjs +0 -3
- package/dist/packem_shared/NotEmptyError-BWGfec5K.cjs +0 -1
- package/dist/packem_shared/NotEmptyError-DMh1o7UL.mjs +0 -1
- package/dist/packem_shared/NotFoundError-Diij7oqe.cjs +0 -1
- package/dist/packem_shared/NotFoundError-T95YsWYl.mjs +0 -1
- package/dist/packem_shared/PermissionError-B8oi38Bx.mjs +0 -1
- package/dist/packem_shared/PermissionError-Ck1Es7al.cjs +0 -1
- package/dist/packem_shared/WalkError-BsngoIKJ.mjs +0 -1
- package/dist/packem_shared/WalkError-gKgp0TWD.cjs +0 -1
- package/dist/packem_shared/assertValidFileContents-BLhwm7u2.mjs +0 -1
- package/dist/packem_shared/assertValidFileContents-CrbDz09d.cjs +0 -1
- package/dist/packem_shared/assertValidFileOrDirectoryPath-DgPIPmZT.mjs +0 -1
- package/dist/packem_shared/assertValidFileOrDirectoryPath-HOUs73Jk.cjs +0 -1
- package/dist/packem_shared/collect-4au76gDu.cjs +0 -1
- package/dist/packem_shared/collect-CRzGiRGg.mjs +0 -1
- package/dist/packem_shared/collectSync-BE8DAOke.mjs +0 -1
- package/dist/packem_shared/collectSync-CbKwt8rz.cjs +0 -1
- package/dist/packem_shared/emptyDir-D2m8OP8u.mjs +0 -1
- package/dist/packem_shared/emptyDir-DKxQHQQb.cjs +0 -1
- package/dist/packem_shared/emptyDirSync-CLM_zyIb.cjs +0 -1
- package/dist/packem_shared/emptyDirSync-CZNcW4wc.mjs +0 -1
- package/dist/packem_shared/ensureDir-BtvxsJiS.mjs +0 -1
- package/dist/packem_shared/ensureDir-DVHj-_yp.cjs +0 -1
- package/dist/packem_shared/ensureDirSync-CvjJ3bGq.cjs +0 -1
- package/dist/packem_shared/ensureDirSync-bGe0QB7d.mjs +0 -1
- package/dist/packem_shared/ensureFile-C46R6-4l.mjs +0 -1
- package/dist/packem_shared/ensureFile-CcJ5XIZm.cjs +0 -1
- package/dist/packem_shared/ensureFileSync-CwYTIP4G.mjs +0 -1
- package/dist/packem_shared/ensureFileSync-v-PhMLTr.cjs +0 -1
- package/dist/packem_shared/ensureLink-63XWiA3I.mjs +0 -1
- package/dist/packem_shared/ensureLink-C-v4AxzH.cjs +0 -1
- package/dist/packem_shared/ensureLinkSync-C4S-zdVb.cjs +0 -1
- package/dist/packem_shared/ensureLinkSync-D2LVObKd.mjs +0 -1
- package/dist/packem_shared/ensureSymlink-C5cy9585.cjs +0 -1
- package/dist/packem_shared/ensureSymlink-D36fS4KE.mjs +0 -1
- package/dist/packem_shared/ensureSymlinkSync-PvWVgeXc.mjs +0 -1
- package/dist/packem_shared/ensureSymlinkSync-YDRbg9hX.cjs +0 -1
- package/dist/packem_shared/findUp-CMGMYNty.mjs +0 -1
- package/dist/packem_shared/findUp-VKPTLmQQ.cjs +0 -1
- package/dist/packem_shared/findUpSync-BFwDGxkV.cjs +0 -1
- package/dist/packem_shared/findUpSync-QP_ZEsJN.mjs +0 -1
- package/dist/packem_shared/get-file-info-type-BXcpoWEM.cjs +0 -1
- package/dist/packem_shared/get-file-info-type-CaWGXRjY.mjs +0 -1
- package/dist/packem_shared/index-Cms6lU4T.cjs +0 -1
- package/dist/packem_shared/index-VcQXVcaq.mjs +0 -1
- package/dist/packem_shared/is-stats-identical-CPCumzsC.cjs +0 -1
- package/dist/packem_shared/is-stats-identical-CS5Y91zW.mjs +0 -1
- package/dist/packem_shared/isAccessible-Be3NKjOk.cjs +0 -1
- package/dist/packem_shared/isAccessible-cO53WedI.mjs +0 -1
- package/dist/packem_shared/isAccessibleSync-D5Vc2GTD.mjs +0 -1
- package/dist/packem_shared/isAccessibleSync-WOSgkAy2.cjs +0 -1
- package/dist/packem_shared/move-MZ9F6paN.mjs +0 -1
- package/dist/packem_shared/move-j3mzcWrG.cjs +0 -1
- package/dist/packem_shared/parseJson-BIYrZWHm.mjs +0 -6
- package/dist/packem_shared/parseJson-CXe73j5t.cjs +0 -6
- package/dist/packem_shared/readFile-CFus1Rym.mjs +0 -1
- package/dist/packem_shared/readFile-fzYtUKuW.cjs +0 -1
- package/dist/packem_shared/readFileSync-Dz4jLcWc.cjs +0 -1
- package/dist/packem_shared/readFileSync-Ulz6QzOz.mjs +0 -1
- package/dist/packem_shared/readJson-C6RN16Rf.mjs +0 -1
- package/dist/packem_shared/readJson-D7_CYUJX.cjs +0 -1
- package/dist/packem_shared/readJsonSync-QziPGqW_.cjs +0 -1
- package/dist/packem_shared/readJsonSync-ztZXpE8z.mjs +0 -1
- package/dist/packem_shared/readYaml-C-ui8qXw.cjs +0 -1
- package/dist/packem_shared/readYaml-aFHfT-4e.mjs +0 -1
- package/dist/packem_shared/readYamlSync-CeJ6RnoJ.mjs +0 -1
- package/dist/packem_shared/readYamlSync-DUYMSemC.cjs +0 -1
- package/dist/packem_shared/remove-B-9MI2l5.cjs +0 -1
- package/dist/packem_shared/remove-DzfvbZOm.mjs +0 -1
- package/dist/packem_shared/removeSync-CJPR6M7V.cjs +0 -1
- package/dist/packem_shared/removeSync-D165rXSn.mjs +0 -1
- package/dist/packem_shared/resolve-symlink-target-BofZSDIc.mjs +0 -1
- package/dist/packem_shared/resolve-symlink-target-HnbdXA1S.cjs +0 -1
- package/dist/packem_shared/stripJsonComments-CKgR4nW4.mjs +0 -1
- package/dist/packem_shared/stripJsonComments-Cw7UCxI3.cjs +0 -1
- package/dist/packem_shared/to-uint-8-array-2-3EvGd7.cjs +0 -1
- package/dist/packem_shared/to-uint-8-array-DwgaTasY.mjs +0 -1
- package/dist/packem_shared/walk-BJgnJy5d.cjs +0 -1
- package/dist/packem_shared/walk-DH-95i_B.mjs +0 -1
- package/dist/packem_shared/walk-include-B-MbUqMt.mjs +0 -1
- package/dist/packem_shared/walk-include-CFIYniQi.cjs +0 -1
- package/dist/packem_shared/walkSync-D4zvt_kM.mjs +0 -1
- package/dist/packem_shared/walkSync-DYawhxUA.cjs +0 -1
- package/dist/packem_shared/writeFile-DaHzc_FW.mjs +0 -1
- package/dist/packem_shared/writeFile-WCuWZNRy.cjs +0 -1
- package/dist/packem_shared/writeFileSync-D9HGh6J-.mjs +0 -1
- package/dist/packem_shared/writeFileSync-Ds49_ORi.cjs +0 -1
- package/dist/packem_shared/writeJson-BdjtBy1t.cjs +0 -4
- package/dist/packem_shared/writeJson-Bu7Dw4Uu.mjs +0 -4
- package/dist/packem_shared/writeJsonSync-7CjNn7oo.mjs +0 -4
- package/dist/packem_shared/writeJsonSync-CdC3ahaO.cjs +0 -4
- package/dist/packem_shared/writeYaml-COWffUNm.cjs +0 -1
- package/dist/packem_shared/writeYaml-bi1dx696.mjs +0 -1
- package/dist/packem_shared/writeYamlSync-BpIN1tTP.cjs +0 -1
- package/dist/packem_shared/writeYamlSync-D2VPlEws.mjs +0 -1
|
@@ -0,0 +1,110 @@
|
|
|
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 === undefined ? [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 !== undefined) {
|
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
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;
|
|
@@ -0,0 +1,5 @@
|
|
|
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 };
|
|
@@ -0,0 +1,20 @@
|
|
|
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 };
|
|
@@ -0,0 +1,22 @@
|
|
|
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;
|
|
@@ -0,0 +1,20 @@
|
|
|
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 };
|
|
@@ -0,0 +1,22 @@
|
|
|
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;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { cwd } from 'node:process';
|
|
2
|
+
import { toPath } from '@visulima/path/utils';
|
|
3
|
+
import { mkdir, rename as rename$1, copyFile, unlink } from 'node:fs/promises';
|
|
4
|
+
import { dirname, resolve } from '@visulima/path';
|
|
5
|
+
import isAccessible from './isAccessible-Bonsm1Ez.mjs';
|
|
6
|
+
import { mkdirSync, renameSync as renameSync$1, copyFileSync, unlinkSync } from 'node:fs';
|
|
7
|
+
import isAccessibleSync from './isAccessibleSync-3gnUWUwX.mjs';
|
|
8
|
+
|
|
9
|
+
var __defProp$3 = Object.defineProperty;
|
|
10
|
+
var __name$3 = (target, value) => __defProp$3(target, "name", { value, configurable: true });
|
|
11
|
+
class SameDirectoryError extends Error {
|
|
12
|
+
static {
|
|
13
|
+
__name$3(this, "SameDirectoryError");
|
|
14
|
+
}
|
|
15
|
+
constructor(source, destination) {
|
|
16
|
+
super(`Source directory "${dirname(source)}" does not match destination directory "${dirname(destination)}"`);
|
|
17
|
+
this.name = "SameDirectoryError";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const validateSameDirectory = /* @__PURE__ */ __name$3((source, destination) => {
|
|
21
|
+
if (!source || !destination) {
|
|
22
|
+
throw new Error("Source and destination paths must not be empty");
|
|
23
|
+
}
|
|
24
|
+
if (dirname(source) !== dirname(destination)) {
|
|
25
|
+
throw new SameDirectoryError(source, destination);
|
|
26
|
+
}
|
|
27
|
+
}, "validateSameDirectory");
|
|
28
|
+
|
|
29
|
+
var __defProp$2 = Object.defineProperty;
|
|
30
|
+
var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
|
|
31
|
+
const internalMoveFile = /* @__PURE__ */ __name$2(async (sourcePath, destinationPath, { cwd, directoryMode, overwrite, validateDirectory }) => {
|
|
32
|
+
if (cwd) {
|
|
33
|
+
sourcePath = resolve(cwd, sourcePath);
|
|
34
|
+
destinationPath = resolve(cwd, destinationPath);
|
|
35
|
+
}
|
|
36
|
+
if (validateDirectory) {
|
|
37
|
+
validateSameDirectory(sourcePath, destinationPath);
|
|
38
|
+
}
|
|
39
|
+
if (!overwrite && await isAccessible(destinationPath)) {
|
|
40
|
+
throw new Error(`The destination file exists: ${destinationPath}`);
|
|
41
|
+
}
|
|
42
|
+
await mkdir(dirname(destinationPath), {
|
|
43
|
+
mode: directoryMode,
|
|
44
|
+
recursive: true
|
|
45
|
+
});
|
|
46
|
+
try {
|
|
47
|
+
await rename$1(sourcePath, destinationPath);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
if (error.code === "EXDEV") {
|
|
50
|
+
await copyFile(sourcePath, destinationPath);
|
|
51
|
+
await unlink(sourcePath);
|
|
52
|
+
} else {
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}, "internalMoveFile");
|
|
57
|
+
|
|
58
|
+
var __defProp$1 = Object.defineProperty;
|
|
59
|
+
var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
|
|
60
|
+
const internalMoveFileSync = /* @__PURE__ */ __name$1((sourcePath, destinationPath, { cwd, directoryMode, overwrite, validateDirectory }) => {
|
|
61
|
+
if (cwd) {
|
|
62
|
+
sourcePath = resolve(cwd, sourcePath);
|
|
63
|
+
destinationPath = resolve(cwd, destinationPath);
|
|
64
|
+
}
|
|
65
|
+
if (validateDirectory) {
|
|
66
|
+
validateSameDirectory(sourcePath, destinationPath);
|
|
67
|
+
}
|
|
68
|
+
if (!overwrite && isAccessibleSync(destinationPath)) {
|
|
69
|
+
throw new Error(`The destination file exists: ${destinationPath}`);
|
|
70
|
+
}
|
|
71
|
+
mkdirSync(dirname(destinationPath), {
|
|
72
|
+
mode: directoryMode,
|
|
73
|
+
recursive: true
|
|
74
|
+
});
|
|
75
|
+
try {
|
|
76
|
+
renameSync$1(sourcePath, destinationPath);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (error.code === "EXDEV") {
|
|
79
|
+
copyFileSync(sourcePath, destinationPath);
|
|
80
|
+
unlinkSync(sourcePath);
|
|
81
|
+
} else {
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}, "internalMoveFileSync");
|
|
86
|
+
|
|
87
|
+
var __defProp = Object.defineProperty;
|
|
88
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
89
|
+
const move = /* @__PURE__ */ __name(async (sourcePath, destinationPath, options = {}) => {
|
|
90
|
+
const internalOptions = {
|
|
91
|
+
overwrite: true,
|
|
92
|
+
validateDirectory: false,
|
|
93
|
+
...options,
|
|
94
|
+
cwd: options.cwd ? toPath(options.cwd) : cwd()
|
|
95
|
+
};
|
|
96
|
+
await internalMoveFile(sourcePath, destinationPath, internalOptions);
|
|
97
|
+
}, "move");
|
|
98
|
+
const moveSync = /* @__PURE__ */ __name((sourcePath, destinationPath, options) => {
|
|
99
|
+
const internalOptions = { overwrite: true, validateDirectory: false, ...options };
|
|
100
|
+
internalOptions.cwd = internalOptions.cwd ? toPath(internalOptions.cwd) : cwd();
|
|
101
|
+
internalMoveFileSync(sourcePath, destinationPath, internalOptions);
|
|
102
|
+
}, "moveSync");
|
|
103
|
+
const rename = /* @__PURE__ */ __name(async (source, destination, options) => {
|
|
104
|
+
const internalOptions = { overwrite: true, ...options, validateDirectory: true };
|
|
105
|
+
internalOptions.cwd = internalOptions.cwd ? toPath(internalOptions.cwd) : cwd();
|
|
106
|
+
await internalMoveFile(source, destination, internalOptions);
|
|
107
|
+
}, "rename");
|
|
108
|
+
const renameSync = /* @__PURE__ */ __name((source, destination, options) => {
|
|
109
|
+
const internalOptions = { overwrite: true, ...options, validateDirectory: true };
|
|
110
|
+
internalOptions.cwd = internalOptions.cwd ? toPath(internalOptions.cwd) : cwd();
|
|
111
|
+
internalMoveFileSync(source, destination, internalOptions);
|
|
112
|
+
}, "renameSync");
|
|
113
|
+
|
|
114
|
+
export { move, moveSync, rename, renameSync };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
+
|
|
5
|
+
const node_process = require('node:process');
|
|
6
|
+
const utils = require('@visulima/path/utils');
|
|
7
|
+
const promises = require('node:fs/promises');
|
|
8
|
+
const path = require('@visulima/path');
|
|
9
|
+
const isAccessible = require('./isAccessible-ZNVGsSb7.cjs');
|
|
10
|
+
const node_fs = require('node:fs');
|
|
11
|
+
const isAccessibleSync = require('./isAccessibleSync-VWjQa-US.cjs');
|
|
12
|
+
|
|
13
|
+
var __defProp$3 = Object.defineProperty;
|
|
14
|
+
var __name$3 = (target, value) => __defProp$3(target, "name", { value, configurable: true });
|
|
15
|
+
class SameDirectoryError extends Error {
|
|
16
|
+
static {
|
|
17
|
+
__name$3(this, "SameDirectoryError");
|
|
18
|
+
}
|
|
19
|
+
constructor(source, destination) {
|
|
20
|
+
super(`Source directory "${path.dirname(source)}" does not match destination directory "${path.dirname(destination)}"`);
|
|
21
|
+
this.name = "SameDirectoryError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const validateSameDirectory = /* @__PURE__ */ __name$3((source, destination) => {
|
|
25
|
+
if (!source || !destination) {
|
|
26
|
+
throw new Error("Source and destination paths must not be empty");
|
|
27
|
+
}
|
|
28
|
+
if (path.dirname(source) !== path.dirname(destination)) {
|
|
29
|
+
throw new SameDirectoryError(source, destination);
|
|
30
|
+
}
|
|
31
|
+
}, "validateSameDirectory");
|
|
32
|
+
|
|
33
|
+
var __defProp$2 = Object.defineProperty;
|
|
34
|
+
var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
|
|
35
|
+
const internalMoveFile = /* @__PURE__ */ __name$2(async (sourcePath, destinationPath, { cwd, directoryMode, overwrite, validateDirectory }) => {
|
|
36
|
+
if (cwd) {
|
|
37
|
+
sourcePath = path.resolve(cwd, sourcePath);
|
|
38
|
+
destinationPath = path.resolve(cwd, destinationPath);
|
|
39
|
+
}
|
|
40
|
+
if (validateDirectory) {
|
|
41
|
+
validateSameDirectory(sourcePath, destinationPath);
|
|
42
|
+
}
|
|
43
|
+
if (!overwrite && await isAccessible(destinationPath)) {
|
|
44
|
+
throw new Error(`The destination file exists: ${destinationPath}`);
|
|
45
|
+
}
|
|
46
|
+
await promises.mkdir(path.dirname(destinationPath), {
|
|
47
|
+
mode: directoryMode,
|
|
48
|
+
recursive: true
|
|
49
|
+
});
|
|
50
|
+
try {
|
|
51
|
+
await promises.rename(sourcePath, destinationPath);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (error.code === "EXDEV") {
|
|
54
|
+
await promises.copyFile(sourcePath, destinationPath);
|
|
55
|
+
await promises.unlink(sourcePath);
|
|
56
|
+
} else {
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}, "internalMoveFile");
|
|
61
|
+
|
|
62
|
+
var __defProp$1 = Object.defineProperty;
|
|
63
|
+
var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
|
|
64
|
+
const internalMoveFileSync = /* @__PURE__ */ __name$1((sourcePath, destinationPath, { cwd, directoryMode, overwrite, validateDirectory }) => {
|
|
65
|
+
if (cwd) {
|
|
66
|
+
sourcePath = path.resolve(cwd, sourcePath);
|
|
67
|
+
destinationPath = path.resolve(cwd, destinationPath);
|
|
68
|
+
}
|
|
69
|
+
if (validateDirectory) {
|
|
70
|
+
validateSameDirectory(sourcePath, destinationPath);
|
|
71
|
+
}
|
|
72
|
+
if (!overwrite && isAccessibleSync(destinationPath)) {
|
|
73
|
+
throw new Error(`The destination file exists: ${destinationPath}`);
|
|
74
|
+
}
|
|
75
|
+
node_fs.mkdirSync(path.dirname(destinationPath), {
|
|
76
|
+
mode: directoryMode,
|
|
77
|
+
recursive: true
|
|
78
|
+
});
|
|
79
|
+
try {
|
|
80
|
+
node_fs.renameSync(sourcePath, destinationPath);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
if (error.code === "EXDEV") {
|
|
83
|
+
node_fs.copyFileSync(sourcePath, destinationPath);
|
|
84
|
+
node_fs.unlinkSync(sourcePath);
|
|
85
|
+
} else {
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, "internalMoveFileSync");
|
|
90
|
+
|
|
91
|
+
var __defProp = Object.defineProperty;
|
|
92
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
93
|
+
const move = /* @__PURE__ */ __name(async (sourcePath, destinationPath, options = {}) => {
|
|
94
|
+
const internalOptions = {
|
|
95
|
+
overwrite: true,
|
|
96
|
+
validateDirectory: false,
|
|
97
|
+
...options,
|
|
98
|
+
cwd: options.cwd ? utils.toPath(options.cwd) : node_process.cwd()
|
|
99
|
+
};
|
|
100
|
+
await internalMoveFile(sourcePath, destinationPath, internalOptions);
|
|
101
|
+
}, "move");
|
|
102
|
+
const moveSync = /* @__PURE__ */ __name((sourcePath, destinationPath, options) => {
|
|
103
|
+
const internalOptions = { overwrite: true, validateDirectory: false, ...options };
|
|
104
|
+
internalOptions.cwd = internalOptions.cwd ? utils.toPath(internalOptions.cwd) : node_process.cwd();
|
|
105
|
+
internalMoveFileSync(sourcePath, destinationPath, internalOptions);
|
|
106
|
+
}, "moveSync");
|
|
107
|
+
const rename = /* @__PURE__ */ __name(async (source, destination, options) => {
|
|
108
|
+
const internalOptions = { overwrite: true, ...options, validateDirectory: true };
|
|
109
|
+
internalOptions.cwd = internalOptions.cwd ? utils.toPath(internalOptions.cwd) : node_process.cwd();
|
|
110
|
+
await internalMoveFile(source, destination, internalOptions);
|
|
111
|
+
}, "rename");
|
|
112
|
+
const renameSync = /* @__PURE__ */ __name((source, destination, options) => {
|
|
113
|
+
const internalOptions = { overwrite: true, ...options, validateDirectory: true };
|
|
114
|
+
internalOptions.cwd = internalOptions.cwd ? utils.toPath(internalOptions.cwd) : node_process.cwd();
|
|
115
|
+
internalMoveFileSync(source, destination, internalOptions);
|
|
116
|
+
}, "renameSync");
|
|
117
|
+
|
|
118
|
+
exports.move = move;
|
|
119
|
+
exports.moveSync = moveSync;
|
|
120
|
+
exports.rename = rename;
|
|
121
|
+
exports.renameSync = renameSync;
|