@visulima/fs 3.1.7 → 3.1.9
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/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.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-BEnYqLIc.mjs +6 -0
- package/dist/packem_shared/parseJson-CQlz8sBs.cjs +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-CiDugsbt.mjs +1 -0
- package/dist/packem_shared/readJson-DtH0Cn36.cjs +1 -0
- package/dist/packem_shared/readJsonSync-B47Fk6n-.mjs +1 -0
- package/dist/packem_shared/readJsonSync-_SoI70cG.cjs +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/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.mjs +1 -6
- package/dist/yaml.cjs +1 -15
- 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,121 +0,0 @@
|
|
|
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;
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import JSONError from './JSONError-CaKt7MhC.mjs';
|
|
2
|
-
|
|
3
|
-
var __defProp$2 = Object.defineProperty;
|
|
4
|
-
var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
|
|
5
|
-
var __defProp$2$1 = Object.defineProperty;
|
|
6
|
-
var __name$2$1 = /* @__PURE__ */ __name$2((target, value) => __defProp$2$1(target, "name", { value, configurable: true }), "__name$2");
|
|
7
|
-
const normalizeLF = /* @__PURE__ */ __name$2$1((code) => code.replaceAll(/\r\n|\r(?!\n)|\n/gu, "\n"), "normalizeLF");
|
|
8
|
-
const _process = globalThis.process || /* @__PURE__ */ Object.create(null);
|
|
9
|
-
const processShims = {
|
|
10
|
-
versions: {}
|
|
11
|
-
};
|
|
12
|
-
const process = new Proxy(_process, {
|
|
13
|
-
get(target, property) {
|
|
14
|
-
if (property in target) {
|
|
15
|
-
return target[property];
|
|
16
|
-
}
|
|
17
|
-
if (property in processShims) {
|
|
18
|
-
return processShims[property];
|
|
19
|
-
}
|
|
20
|
-
return void 0;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
var __defProp$1$1 = Object.defineProperty;
|
|
24
|
-
var __name$1$1 = /* @__PURE__ */ __name$2((target, value) => __defProp$1$1(target, "name", { value, configurable: true }), "__name$1");
|
|
25
|
-
const getMarkerLines = /* @__PURE__ */ __name$1$1((loc, source, linesAbove, linesBelow) => {
|
|
26
|
-
const startLoc = {
|
|
27
|
-
column: 0,
|
|
28
|
-
// @ts-expect-error Can be overwritten
|
|
29
|
-
line: -1,
|
|
30
|
-
...loc.start
|
|
31
|
-
};
|
|
32
|
-
const endLoc = {
|
|
33
|
-
...startLoc,
|
|
34
|
-
...loc.end
|
|
35
|
-
};
|
|
36
|
-
const startLine = startLoc.line;
|
|
37
|
-
const startColumn = startLoc.column;
|
|
38
|
-
const endLine = endLoc.line;
|
|
39
|
-
const endColumn = endLoc.column;
|
|
40
|
-
let start = Math.max(startLine - (linesAbove + 1), 0);
|
|
41
|
-
let end = Math.min(source.length, endLine + linesBelow);
|
|
42
|
-
if (startLine === -1) {
|
|
43
|
-
start = 0;
|
|
44
|
-
}
|
|
45
|
-
if (endLine === -1) {
|
|
46
|
-
end = source.length;
|
|
47
|
-
}
|
|
48
|
-
const lineDiff = endLine - startLine;
|
|
49
|
-
const markerLines = {};
|
|
50
|
-
if (lineDiff) {
|
|
51
|
-
for (let index = 0; index <= lineDiff; index++) {
|
|
52
|
-
const lineNumber = index + startLine;
|
|
53
|
-
if (!startColumn) {
|
|
54
|
-
markerLines[lineNumber] = true;
|
|
55
|
-
} else if (index === 0) {
|
|
56
|
-
const sourceLength = source[lineNumber - 1]?.length;
|
|
57
|
-
markerLines[lineNumber] = [startColumn, (sourceLength ?? 0) - startColumn + 1];
|
|
58
|
-
} else if (index === lineDiff) {
|
|
59
|
-
markerLines[lineNumber] = [0, endColumn];
|
|
60
|
-
} else {
|
|
61
|
-
const sourceLength = source[lineNumber - index]?.length;
|
|
62
|
-
markerLines[lineNumber] = [0, sourceLength];
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
} else if (startColumn === endColumn) {
|
|
66
|
-
markerLines[startLine] = startColumn ? [startColumn, 0] : true;
|
|
67
|
-
} else {
|
|
68
|
-
markerLines[startLine] = [startColumn, (endColumn ?? 0) - (startColumn ?? 0)];
|
|
69
|
-
}
|
|
70
|
-
return { end, markerLines, start };
|
|
71
|
-
}, "getMarkerLines");
|
|
72
|
-
var __defProp2$1 = Object.defineProperty;
|
|
73
|
-
var __name2$1 = /* @__PURE__ */ __name$2((target, value) => __defProp2$1(target, "name", { value, configurable: true }), "__name");
|
|
74
|
-
const CODE_FRAME_POINTER = process.platform === "win32" && !process.env?.WT_SESSION ? ">" : "❯";
|
|
75
|
-
const codeFrame = /* @__PURE__ */ __name2$1((source, loc, options) => {
|
|
76
|
-
const config = {
|
|
77
|
-
// grab 2 lines before, and 3 lines after focused line
|
|
78
|
-
linesAbove: 2,
|
|
79
|
-
linesBelow: 3,
|
|
80
|
-
prefix: "",
|
|
81
|
-
showGutter: true,
|
|
82
|
-
tabWidth: 4,
|
|
83
|
-
...options,
|
|
84
|
-
color: {
|
|
85
|
-
gutter: /* @__PURE__ */ __name2$1((value) => value, "gutter"),
|
|
86
|
-
marker: /* @__PURE__ */ __name2$1((value) => value, "marker"),
|
|
87
|
-
message: /* @__PURE__ */ __name2$1((value) => value, "message"),
|
|
88
|
-
...options?.color
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
const hasColumns = loc.start && typeof loc.start.column === "number";
|
|
92
|
-
let lines = normalizeLF(source).split("\n");
|
|
93
|
-
if (typeof config?.tabWidth === "number") {
|
|
94
|
-
lines = lines.map((ln) => ln.replaceAll(" ", " ".repeat(config.tabWidth)));
|
|
95
|
-
}
|
|
96
|
-
const { end, markerLines, start } = getMarkerLines(loc, lines, config.linesAbove, config.linesBelow);
|
|
97
|
-
const numberMaxWidth = String(end).length;
|
|
98
|
-
const { gutter: colorizeGutter, marker: colorizeMarker, message: colorizeMessage } = config.color;
|
|
99
|
-
let frame = lines.slice(start, end).map((line, index) => {
|
|
100
|
-
const number = start + 1 + index;
|
|
101
|
-
const hasMarker = markerLines[number];
|
|
102
|
-
const paddedNumber = (" " + number).slice(-numberMaxWidth);
|
|
103
|
-
const lastMarkerLine = !markerLines[number + 1];
|
|
104
|
-
const gutter = " " + paddedNumber + (config.showGutter ? " |" : "");
|
|
105
|
-
if (hasMarker) {
|
|
106
|
-
let markerLine = "";
|
|
107
|
-
if (Array.isArray(hasMarker)) {
|
|
108
|
-
const markerSpacing = line.replaceAll(/[^\t]/g, " ").slice(0, Math.max(hasMarker[0] - 1, 0));
|
|
109
|
-
const numberOfMarkers = hasMarker[1] || 1;
|
|
110
|
-
markerLine = [
|
|
111
|
-
"\n ",
|
|
112
|
-
config.prefix + colorizeGutter(gutter.replaceAll(/\d/g, " ")),
|
|
113
|
-
" ",
|
|
114
|
-
markerSpacing,
|
|
115
|
-
colorizeMarker("^").repeat(numberOfMarkers)
|
|
116
|
-
].join("");
|
|
117
|
-
if (lastMarkerLine && config.message) {
|
|
118
|
-
markerLine += ` ${colorizeMessage(config.message)}`;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return [config.prefix + colorizeMarker(CODE_FRAME_POINTER), colorizeGutter(gutter), line.length > 0 ? " " + line : "", markerLine].join("");
|
|
122
|
-
}
|
|
123
|
-
return config.prefix + " " + colorizeGutter(gutter) + (line.length > 0 ? " " + line : "");
|
|
124
|
-
}).join("\n");
|
|
125
|
-
if (config.message && !hasColumns) {
|
|
126
|
-
frame = config.prefix + " ".repeat(numberMaxWidth + 1) + config.message + "\n" + frame;
|
|
127
|
-
}
|
|
128
|
-
return frame;
|
|
129
|
-
}, "codeFrame");
|
|
130
|
-
|
|
131
|
-
var __defProp$1 = Object.defineProperty;
|
|
132
|
-
var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
|
|
133
|
-
var __defProp2 = Object.defineProperty;
|
|
134
|
-
var __name2 = /* @__PURE__ */ __name$1((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
135
|
-
const binarySearch = /* @__PURE__ */ __name2((element, array) => {
|
|
136
|
-
let m = 0;
|
|
137
|
-
let n = array.length - 2;
|
|
138
|
-
while (m < n) {
|
|
139
|
-
const key = m + (n - m >> 1);
|
|
140
|
-
if (element < array[key]) {
|
|
141
|
-
n = key - 1;
|
|
142
|
-
} else if (element >= array[key + 1]) {
|
|
143
|
-
m = key + 1;
|
|
144
|
-
} else {
|
|
145
|
-
m = key;
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return m;
|
|
150
|
-
}, "binarySearch");
|
|
151
|
-
const getLineStartIndexes = /* @__PURE__ */ __name2((string_) => (
|
|
152
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
153
|
-
string_.split(/\n|\r(?!\n)/).reduce(
|
|
154
|
-
(accumulator, current) => {
|
|
155
|
-
accumulator.push(accumulator.at(-1) + current.length + 1);
|
|
156
|
-
return accumulator;
|
|
157
|
-
},
|
|
158
|
-
[0]
|
|
159
|
-
)
|
|
160
|
-
), "getLineStartIndexes");
|
|
161
|
-
const indexToLineColumn = /* @__PURE__ */ __name2((input, index, options) => {
|
|
162
|
-
const skipChecks = options?.skipChecks ?? false;
|
|
163
|
-
if (!skipChecks && (!Array.isArray(input) && typeof input !== "string" || (typeof input === "string" || Array.isArray(input)) && input.length === 0)) {
|
|
164
|
-
return { column: 0, line: 0 };
|
|
165
|
-
}
|
|
166
|
-
if (!skipChecks && (typeof index !== "number" || typeof input === "string" && index >= input.length || Array.isArray(input) && index + 1 >= input.at(-1))) {
|
|
167
|
-
return { column: 0, line: 0 };
|
|
168
|
-
}
|
|
169
|
-
if (typeof input === "string") {
|
|
170
|
-
const startIndexesOfEachLine = getLineStartIndexes(input);
|
|
171
|
-
const line2 = binarySearch(index, startIndexesOfEachLine);
|
|
172
|
-
return {
|
|
173
|
-
// eslint-disable-next-line security/detect-object-injection
|
|
174
|
-
column: index - startIndexesOfEachLine[line2] + 1,
|
|
175
|
-
line: line2 + 1
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
const line = binarySearch(index, input);
|
|
179
|
-
return {
|
|
180
|
-
// eslint-disable-next-line security/detect-object-injection
|
|
181
|
-
column: index - input[line] + 1,
|
|
182
|
-
line: line + 1
|
|
183
|
-
};
|
|
184
|
-
}, "indexToLineColumn");
|
|
185
|
-
|
|
186
|
-
var __defProp = Object.defineProperty;
|
|
187
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
188
|
-
const getCodePoint = /* @__PURE__ */ __name((character) => `\\u{${character.codePointAt(0).toString(16)}}`, "getCodePoint");
|
|
189
|
-
const generateCodeFrame = /* @__PURE__ */ __name((source, location, options) => codeFrame(
|
|
190
|
-
source,
|
|
191
|
-
{ start: location },
|
|
192
|
-
{
|
|
193
|
-
tabWidth: false,
|
|
194
|
-
...options
|
|
195
|
-
}
|
|
196
|
-
), "generateCodeFrame");
|
|
197
|
-
const getErrorLocation = /* @__PURE__ */ __name((source, message) => {
|
|
198
|
-
const match = /in JSON at position (?<index>\d+)(?: \(line (?<line>\d+) column (?<column>\d+)\))?$/.exec(message);
|
|
199
|
-
if (!match) {
|
|
200
|
-
return void 0;
|
|
201
|
-
}
|
|
202
|
-
let { column, index, line } = match.groups;
|
|
203
|
-
if (line && column) {
|
|
204
|
-
return { column: Number(column), line: Number(line) };
|
|
205
|
-
}
|
|
206
|
-
index = Number(index);
|
|
207
|
-
if (index === source.length) {
|
|
208
|
-
index = source.length - 1;
|
|
209
|
-
}
|
|
210
|
-
return indexToLineColumn(source, index);
|
|
211
|
-
}, "getErrorLocation");
|
|
212
|
-
const addCodePointToUnexpectedToken = /* @__PURE__ */ __name((message) => message.replace(
|
|
213
|
-
// TODO[engine:node@>=20]: The token always quoted after Node.js 20
|
|
214
|
-
// eslint-disable-next-line regexp/no-potentially-useless-backreference
|
|
215
|
-
/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,
|
|
216
|
-
(_, _quote, token) => `"${token}"(${getCodePoint(token)})`
|
|
217
|
-
), "addCodePointToUnexpectedToken");
|
|
218
|
-
function parseJson(string, reviver, fileName, options) {
|
|
219
|
-
if (typeof reviver === "string") {
|
|
220
|
-
if (typeof fileName === "object") {
|
|
221
|
-
options = fileName;
|
|
222
|
-
}
|
|
223
|
-
fileName = reviver;
|
|
224
|
-
reviver = void 0;
|
|
225
|
-
}
|
|
226
|
-
let message;
|
|
227
|
-
try {
|
|
228
|
-
return JSON.parse(string, reviver);
|
|
229
|
-
} catch (error) {
|
|
230
|
-
message = error.message;
|
|
231
|
-
}
|
|
232
|
-
let location;
|
|
233
|
-
if (string) {
|
|
234
|
-
location = getErrorLocation(string, message);
|
|
235
|
-
message = addCodePointToUnexpectedToken(message);
|
|
236
|
-
} else {
|
|
237
|
-
message += " while parsing empty string";
|
|
238
|
-
}
|
|
239
|
-
const jsonError = new JSONError(message);
|
|
240
|
-
jsonError.fileName = fileName;
|
|
241
|
-
if (location) {
|
|
242
|
-
jsonError.codeFrame = generateCodeFrame(string, location, options);
|
|
243
|
-
}
|
|
244
|
-
throw jsonError;
|
|
245
|
-
}
|
|
246
|
-
__name(parseJson, "parseJson");
|
|
247
|
-
|
|
248
|
-
export { parseJson as default };
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const JSONError = require('./JSONError-5-wHnrxX.cjs');
|
|
4
|
-
|
|
5
|
-
var __defProp$2 = Object.defineProperty;
|
|
6
|
-
var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
|
|
7
|
-
var __defProp$2$1 = Object.defineProperty;
|
|
8
|
-
var __name$2$1 = /* @__PURE__ */ __name$2((target, value) => __defProp$2$1(target, "name", { value, configurable: true }), "__name$2");
|
|
9
|
-
const normalizeLF = /* @__PURE__ */ __name$2$1((code) => code.replaceAll(/\r\n|\r(?!\n)|\n/gu, "\n"), "normalizeLF");
|
|
10
|
-
const _process = globalThis.process || /* @__PURE__ */ Object.create(null);
|
|
11
|
-
const processShims = {
|
|
12
|
-
versions: {}
|
|
13
|
-
};
|
|
14
|
-
const process = new Proxy(_process, {
|
|
15
|
-
get(target, property) {
|
|
16
|
-
if (property in target) {
|
|
17
|
-
return target[property];
|
|
18
|
-
}
|
|
19
|
-
if (property in processShims) {
|
|
20
|
-
return processShims[property];
|
|
21
|
-
}
|
|
22
|
-
return void 0;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
var __defProp$1$1 = Object.defineProperty;
|
|
26
|
-
var __name$1$1 = /* @__PURE__ */ __name$2((target, value) => __defProp$1$1(target, "name", { value, configurable: true }), "__name$1");
|
|
27
|
-
const getMarkerLines = /* @__PURE__ */ __name$1$1((loc, source, linesAbove, linesBelow) => {
|
|
28
|
-
const startLoc = {
|
|
29
|
-
column: 0,
|
|
30
|
-
// @ts-expect-error Can be overwritten
|
|
31
|
-
line: -1,
|
|
32
|
-
...loc.start
|
|
33
|
-
};
|
|
34
|
-
const endLoc = {
|
|
35
|
-
...startLoc,
|
|
36
|
-
...loc.end
|
|
37
|
-
};
|
|
38
|
-
const startLine = startLoc.line;
|
|
39
|
-
const startColumn = startLoc.column;
|
|
40
|
-
const endLine = endLoc.line;
|
|
41
|
-
const endColumn = endLoc.column;
|
|
42
|
-
let start = Math.max(startLine - (linesAbove + 1), 0);
|
|
43
|
-
let end = Math.min(source.length, endLine + linesBelow);
|
|
44
|
-
if (startLine === -1) {
|
|
45
|
-
start = 0;
|
|
46
|
-
}
|
|
47
|
-
if (endLine === -1) {
|
|
48
|
-
end = source.length;
|
|
49
|
-
}
|
|
50
|
-
const lineDiff = endLine - startLine;
|
|
51
|
-
const markerLines = {};
|
|
52
|
-
if (lineDiff) {
|
|
53
|
-
for (let index = 0; index <= lineDiff; index++) {
|
|
54
|
-
const lineNumber = index + startLine;
|
|
55
|
-
if (!startColumn) {
|
|
56
|
-
markerLines[lineNumber] = true;
|
|
57
|
-
} else if (index === 0) {
|
|
58
|
-
const sourceLength = source[lineNumber - 1]?.length;
|
|
59
|
-
markerLines[lineNumber] = [startColumn, (sourceLength ?? 0) - startColumn + 1];
|
|
60
|
-
} else if (index === lineDiff) {
|
|
61
|
-
markerLines[lineNumber] = [0, endColumn];
|
|
62
|
-
} else {
|
|
63
|
-
const sourceLength = source[lineNumber - index]?.length;
|
|
64
|
-
markerLines[lineNumber] = [0, sourceLength];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
} else if (startColumn === endColumn) {
|
|
68
|
-
markerLines[startLine] = startColumn ? [startColumn, 0] : true;
|
|
69
|
-
} else {
|
|
70
|
-
markerLines[startLine] = [startColumn, (endColumn ?? 0) - (startColumn ?? 0)];
|
|
71
|
-
}
|
|
72
|
-
return { end, markerLines, start };
|
|
73
|
-
}, "getMarkerLines");
|
|
74
|
-
var __defProp2$1 = Object.defineProperty;
|
|
75
|
-
var __name2$1 = /* @__PURE__ */ __name$2((target, value) => __defProp2$1(target, "name", { value, configurable: true }), "__name");
|
|
76
|
-
const CODE_FRAME_POINTER = process.platform === "win32" && !process.env?.WT_SESSION ? ">" : "❯";
|
|
77
|
-
const codeFrame = /* @__PURE__ */ __name2$1((source, loc, options) => {
|
|
78
|
-
const config = {
|
|
79
|
-
// grab 2 lines before, and 3 lines after focused line
|
|
80
|
-
linesAbove: 2,
|
|
81
|
-
linesBelow: 3,
|
|
82
|
-
prefix: "",
|
|
83
|
-
showGutter: true,
|
|
84
|
-
tabWidth: 4,
|
|
85
|
-
...options,
|
|
86
|
-
color: {
|
|
87
|
-
gutter: /* @__PURE__ */ __name2$1((value) => value, "gutter"),
|
|
88
|
-
marker: /* @__PURE__ */ __name2$1((value) => value, "marker"),
|
|
89
|
-
message: /* @__PURE__ */ __name2$1((value) => value, "message"),
|
|
90
|
-
...options?.color
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const hasColumns = loc.start && typeof loc.start.column === "number";
|
|
94
|
-
let lines = normalizeLF(source).split("\n");
|
|
95
|
-
if (typeof config?.tabWidth === "number") {
|
|
96
|
-
lines = lines.map((ln) => ln.replaceAll(" ", " ".repeat(config.tabWidth)));
|
|
97
|
-
}
|
|
98
|
-
const { end, markerLines, start } = getMarkerLines(loc, lines, config.linesAbove, config.linesBelow);
|
|
99
|
-
const numberMaxWidth = String(end).length;
|
|
100
|
-
const { gutter: colorizeGutter, marker: colorizeMarker, message: colorizeMessage } = config.color;
|
|
101
|
-
let frame = lines.slice(start, end).map((line, index) => {
|
|
102
|
-
const number = start + 1 + index;
|
|
103
|
-
const hasMarker = markerLines[number];
|
|
104
|
-
const paddedNumber = (" " + number).slice(-numberMaxWidth);
|
|
105
|
-
const lastMarkerLine = !markerLines[number + 1];
|
|
106
|
-
const gutter = " " + paddedNumber + (config.showGutter ? " |" : "");
|
|
107
|
-
if (hasMarker) {
|
|
108
|
-
let markerLine = "";
|
|
109
|
-
if (Array.isArray(hasMarker)) {
|
|
110
|
-
const markerSpacing = line.replaceAll(/[^\t]/g, " ").slice(0, Math.max(hasMarker[0] - 1, 0));
|
|
111
|
-
const numberOfMarkers = hasMarker[1] || 1;
|
|
112
|
-
markerLine = [
|
|
113
|
-
"\n ",
|
|
114
|
-
config.prefix + colorizeGutter(gutter.replaceAll(/\d/g, " ")),
|
|
115
|
-
" ",
|
|
116
|
-
markerSpacing,
|
|
117
|
-
colorizeMarker("^").repeat(numberOfMarkers)
|
|
118
|
-
].join("");
|
|
119
|
-
if (lastMarkerLine && config.message) {
|
|
120
|
-
markerLine += ` ${colorizeMessage(config.message)}`;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return [config.prefix + colorizeMarker(CODE_FRAME_POINTER), colorizeGutter(gutter), line.length > 0 ? " " + line : "", markerLine].join("");
|
|
124
|
-
}
|
|
125
|
-
return config.prefix + " " + colorizeGutter(gutter) + (line.length > 0 ? " " + line : "");
|
|
126
|
-
}).join("\n");
|
|
127
|
-
if (config.message && !hasColumns) {
|
|
128
|
-
frame = config.prefix + " ".repeat(numberMaxWidth + 1) + config.message + "\n" + frame;
|
|
129
|
-
}
|
|
130
|
-
return frame;
|
|
131
|
-
}, "codeFrame");
|
|
132
|
-
|
|
133
|
-
var __defProp$1 = Object.defineProperty;
|
|
134
|
-
var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
|
|
135
|
-
var __defProp2 = Object.defineProperty;
|
|
136
|
-
var __name2 = /* @__PURE__ */ __name$1((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
137
|
-
const binarySearch = /* @__PURE__ */ __name2((element, array) => {
|
|
138
|
-
let m = 0;
|
|
139
|
-
let n = array.length - 2;
|
|
140
|
-
while (m < n) {
|
|
141
|
-
const key = m + (n - m >> 1);
|
|
142
|
-
if (element < array[key]) {
|
|
143
|
-
n = key - 1;
|
|
144
|
-
} else if (element >= array[key + 1]) {
|
|
145
|
-
m = key + 1;
|
|
146
|
-
} else {
|
|
147
|
-
m = key;
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return m;
|
|
152
|
-
}, "binarySearch");
|
|
153
|
-
const getLineStartIndexes = /* @__PURE__ */ __name2((string_) => (
|
|
154
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
155
|
-
string_.split(/\n|\r(?!\n)/).reduce(
|
|
156
|
-
(accumulator, current) => {
|
|
157
|
-
accumulator.push(accumulator.at(-1) + current.length + 1);
|
|
158
|
-
return accumulator;
|
|
159
|
-
},
|
|
160
|
-
[0]
|
|
161
|
-
)
|
|
162
|
-
), "getLineStartIndexes");
|
|
163
|
-
const indexToLineColumn = /* @__PURE__ */ __name2((input, index, options) => {
|
|
164
|
-
const skipChecks = options?.skipChecks ?? false;
|
|
165
|
-
if (!skipChecks && (!Array.isArray(input) && typeof input !== "string" || (typeof input === "string" || Array.isArray(input)) && input.length === 0)) {
|
|
166
|
-
return { column: 0, line: 0 };
|
|
167
|
-
}
|
|
168
|
-
if (!skipChecks && (typeof index !== "number" || typeof input === "string" && index >= input.length || Array.isArray(input) && index + 1 >= input.at(-1))) {
|
|
169
|
-
return { column: 0, line: 0 };
|
|
170
|
-
}
|
|
171
|
-
if (typeof input === "string") {
|
|
172
|
-
const startIndexesOfEachLine = getLineStartIndexes(input);
|
|
173
|
-
const line2 = binarySearch(index, startIndexesOfEachLine);
|
|
174
|
-
return {
|
|
175
|
-
// eslint-disable-next-line security/detect-object-injection
|
|
176
|
-
column: index - startIndexesOfEachLine[line2] + 1,
|
|
177
|
-
line: line2 + 1
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
const line = binarySearch(index, input);
|
|
181
|
-
return {
|
|
182
|
-
// eslint-disable-next-line security/detect-object-injection
|
|
183
|
-
column: index - input[line] + 1,
|
|
184
|
-
line: line + 1
|
|
185
|
-
};
|
|
186
|
-
}, "indexToLineColumn");
|
|
187
|
-
|
|
188
|
-
var __defProp = Object.defineProperty;
|
|
189
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
190
|
-
const getCodePoint = /* @__PURE__ */ __name((character) => `\\u{${character.codePointAt(0).toString(16)}}`, "getCodePoint");
|
|
191
|
-
const generateCodeFrame = /* @__PURE__ */ __name((source, location, options) => codeFrame(
|
|
192
|
-
source,
|
|
193
|
-
{ start: location },
|
|
194
|
-
{
|
|
195
|
-
tabWidth: false,
|
|
196
|
-
...options
|
|
197
|
-
}
|
|
198
|
-
), "generateCodeFrame");
|
|
199
|
-
const getErrorLocation = /* @__PURE__ */ __name((source, message) => {
|
|
200
|
-
const match = /in JSON at position (?<index>\d+)(?: \(line (?<line>\d+) column (?<column>\d+)\))?$/.exec(message);
|
|
201
|
-
if (!match) {
|
|
202
|
-
return void 0;
|
|
203
|
-
}
|
|
204
|
-
let { column, index, line } = match.groups;
|
|
205
|
-
if (line && column) {
|
|
206
|
-
return { column: Number(column), line: Number(line) };
|
|
207
|
-
}
|
|
208
|
-
index = Number(index);
|
|
209
|
-
if (index === source.length) {
|
|
210
|
-
index = source.length - 1;
|
|
211
|
-
}
|
|
212
|
-
return indexToLineColumn(source, index);
|
|
213
|
-
}, "getErrorLocation");
|
|
214
|
-
const addCodePointToUnexpectedToken = /* @__PURE__ */ __name((message) => message.replace(
|
|
215
|
-
// TODO[engine:node@>=20]: The token always quoted after Node.js 20
|
|
216
|
-
// eslint-disable-next-line regexp/no-potentially-useless-backreference
|
|
217
|
-
/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,
|
|
218
|
-
(_, _quote, token) => `"${token}"(${getCodePoint(token)})`
|
|
219
|
-
), "addCodePointToUnexpectedToken");
|
|
220
|
-
function parseJson(string, reviver, fileName, options) {
|
|
221
|
-
if (typeof reviver === "string") {
|
|
222
|
-
if (typeof fileName === "object") {
|
|
223
|
-
options = fileName;
|
|
224
|
-
}
|
|
225
|
-
fileName = reviver;
|
|
226
|
-
reviver = void 0;
|
|
227
|
-
}
|
|
228
|
-
let message;
|
|
229
|
-
try {
|
|
230
|
-
return JSON.parse(string, reviver);
|
|
231
|
-
} catch (error) {
|
|
232
|
-
message = error.message;
|
|
233
|
-
}
|
|
234
|
-
let location;
|
|
235
|
-
if (string) {
|
|
236
|
-
location = getErrorLocation(string, message);
|
|
237
|
-
message = addCodePointToUnexpectedToken(message);
|
|
238
|
-
} else {
|
|
239
|
-
message += " while parsing empty string";
|
|
240
|
-
}
|
|
241
|
-
const jsonError = new JSONError(message);
|
|
242
|
-
jsonError.fileName = fileName;
|
|
243
|
-
if (location) {
|
|
244
|
-
jsonError.codeFrame = generateCodeFrame(string, location, options);
|
|
245
|
-
}
|
|
246
|
-
throw jsonError;
|
|
247
|
-
}
|
|
248
|
-
__name(parseJson, "parseJson");
|
|
249
|
-
|
|
250
|
-
module.exports = parseJson;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { readFile as readFile$1 } from 'node:fs/promises';
|
|
2
|
-
import { unzip, brotliDecompress } from 'node:zlib';
|
|
3
|
-
import { toPath } from '@visulima/path/utils';
|
|
4
|
-
import { R_OK } from './F_OK-JER1LjUr.mjs';
|
|
5
|
-
import PermissionError from './PermissionError-CqGMI9qC.mjs';
|
|
6
|
-
import isAccessible from './isAccessible-Bonsm1Ez.mjs';
|
|
7
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
|
|
8
|
-
|
|
9
|
-
var __defProp = Object.defineProperty;
|
|
10
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
11
|
-
const decompressionMethods = {
|
|
12
|
-
brotli: brotliDecompress,
|
|
13
|
-
gzip: unzip,
|
|
14
|
-
none: /* @__PURE__ */ __name((buffer, callback) => {
|
|
15
|
-
callback(null, buffer);
|
|
16
|
-
}, "none")
|
|
17
|
-
};
|
|
18
|
-
const readFile = /* @__PURE__ */ __name(async (path, options) => {
|
|
19
|
-
assertValidFileOrDirectoryPath(path);
|
|
20
|
-
path = toPath(path);
|
|
21
|
-
if (!await isAccessible(path)) {
|
|
22
|
-
throw new PermissionError(`unable to read the non-accessible file: ${path}`);
|
|
23
|
-
}
|
|
24
|
-
if (!await isAccessible(path, R_OK)) {
|
|
25
|
-
throw new Error(`Unable to read the non-readable file: ${path}`);
|
|
26
|
-
}
|
|
27
|
-
const { buffer, compression, encoding, flag } = options ?? {};
|
|
28
|
-
return await readFile$1(path, flag ? { encoding, flag } : { encoding }).then(
|
|
29
|
-
async (content) => (
|
|
30
|
-
// eslint-disable-next-line compat/compat
|
|
31
|
-
await new Promise((resolve, reject) => {
|
|
32
|
-
decompressionMethods[compression ?? "none"](content, (error, result) => {
|
|
33
|
-
if (error) {
|
|
34
|
-
reject(error);
|
|
35
|
-
} else {
|
|
36
|
-
resolve(buffer ? result : result.toString());
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
})
|
|
40
|
-
)
|
|
41
|
-
).catch((error) => {
|
|
42
|
-
throw error;
|
|
43
|
-
});
|
|
44
|
-
}, "readFile");
|
|
45
|
-
|
|
46
|
-
export { readFile as default };
|