@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,20 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { mkdir, readdir, rm } from 'node:fs/promises';
|
|
3
|
-
import { join } from '@visulima/path';
|
|
4
|
-
import { toPath } from '@visulima/path/utils';
|
|
5
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
|
|
6
|
-
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
const emptyDir = /* @__PURE__ */ __name(async (dir, options) => {
|
|
10
|
-
assertValidFileOrDirectoryPath(dir);
|
|
11
|
-
if (!existsSync(dir)) {
|
|
12
|
-
await mkdir(dir, { recursive: true });
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
for await (const item of await readdir(dir)) {
|
|
16
|
-
await rm(join(toPath(dir), item), { ...options, force: true, recursive: true });
|
|
17
|
-
}
|
|
18
|
-
}, "emptyDir");
|
|
19
|
-
|
|
20
|
-
export { emptyDir as default };
|
|
@@ -1,21 +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
|
-
|
|
8
|
-
var __defProp = Object.defineProperty;
|
|
9
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
-
const emptyDirSync = /* @__PURE__ */ __name((dir, options) => {
|
|
11
|
-
assertValidFileOrDirectoryPath(dir);
|
|
12
|
-
if (!node_fs.existsSync(dir)) {
|
|
13
|
-
node_fs.mkdirSync(dir, { recursive: true });
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
for (const item of node_fs.readdirSync(dir)) {
|
|
17
|
-
node_fs.rmSync(path.join(utils.toPath(dir), item), { ...options, force: true, recursive: true });
|
|
18
|
-
}
|
|
19
|
-
}, "emptyDirSync");
|
|
20
|
-
|
|
21
|
-
module.exports = emptyDirSync;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readdirSync, rmSync } from 'node:fs';
|
|
2
|
-
import { join } from '@visulima/path';
|
|
3
|
-
import { toPath } from '@visulima/path/utils';
|
|
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
|
-
const emptyDirSync = /* @__PURE__ */ __name((dir, options) => {
|
|
9
|
-
assertValidFileOrDirectoryPath(dir);
|
|
10
|
-
if (!existsSync(dir)) {
|
|
11
|
-
mkdirSync(dir, { recursive: true });
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
for (const item of readdirSync(dir)) {
|
|
15
|
-
rmSync(join(toPath(dir), item), { ...options, force: true, recursive: true });
|
|
16
|
-
}
|
|
17
|
-
}, "emptyDirSync");
|
|
18
|
-
|
|
19
|
-
export { emptyDirSync as default };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const promises = require('node:fs/promises');
|
|
4
|
-
const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs');
|
|
5
|
-
const getFileInfoType = require('./get-file-info-type-BlryFnpp.cjs');
|
|
6
|
-
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
const ensureDir = /* @__PURE__ */ __name(async (directory) => {
|
|
10
|
-
assertValidFileOrDirectoryPath(directory);
|
|
11
|
-
try {
|
|
12
|
-
const fileInfo = await promises.lstat(directory);
|
|
13
|
-
if (!fileInfo.isDirectory()) {
|
|
14
|
-
throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType.getFileInfoType(fileInfo)}'`);
|
|
15
|
-
}
|
|
16
|
-
return;
|
|
17
|
-
} catch (error) {
|
|
18
|
-
if (error.code !== "ENOENT") {
|
|
19
|
-
throw error;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
await promises.mkdir(directory, { recursive: true });
|
|
24
|
-
} catch (error) {
|
|
25
|
-
if (error.code !== "EEXIST") {
|
|
26
|
-
throw error;
|
|
27
|
-
}
|
|
28
|
-
const fileInfo = await promises.lstat(directory);
|
|
29
|
-
if (!fileInfo.isDirectory()) {
|
|
30
|
-
throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType.getFileInfoType(fileInfo)}'`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}, "ensureDir");
|
|
34
|
-
|
|
35
|
-
module.exports = ensureDir;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { lstat, mkdir } from 'node:fs/promises';
|
|
2
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
|
|
3
|
-
import { g as getFileInfoType } from './get-file-info-type-ButUVD6d.mjs';
|
|
4
|
-
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
-
const ensureDir = /* @__PURE__ */ __name(async (directory) => {
|
|
8
|
-
assertValidFileOrDirectoryPath(directory);
|
|
9
|
-
try {
|
|
10
|
-
const fileInfo = await lstat(directory);
|
|
11
|
-
if (!fileInfo.isDirectory()) {
|
|
12
|
-
throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
|
|
13
|
-
}
|
|
14
|
-
return;
|
|
15
|
-
} catch (error) {
|
|
16
|
-
if (error.code !== "ENOENT") {
|
|
17
|
-
throw error;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
await mkdir(directory, { recursive: true });
|
|
22
|
-
} catch (error) {
|
|
23
|
-
if (error.code !== "EEXIST") {
|
|
24
|
-
throw error;
|
|
25
|
-
}
|
|
26
|
-
const fileInfo = await lstat(directory);
|
|
27
|
-
if (!fileInfo.isDirectory()) {
|
|
28
|
-
throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}, "ensureDir");
|
|
32
|
-
|
|
33
|
-
export { ensureDir as default };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const node_fs = require('node:fs');
|
|
4
|
-
const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs');
|
|
5
|
-
const getFileInfoType = require('./get-file-info-type-BlryFnpp.cjs');
|
|
6
|
-
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
const ensureDirSync = /* @__PURE__ */ __name((directory) => {
|
|
10
|
-
assertValidFileOrDirectoryPath(directory);
|
|
11
|
-
try {
|
|
12
|
-
const fileInfo = node_fs.lstatSync(directory);
|
|
13
|
-
if (!fileInfo.isDirectory()) {
|
|
14
|
-
throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType.getFileInfoType(fileInfo)}'`);
|
|
15
|
-
}
|
|
16
|
-
return;
|
|
17
|
-
} catch (error) {
|
|
18
|
-
if (error.code !== "ENOENT") {
|
|
19
|
-
throw error;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
node_fs.mkdirSync(directory, { recursive: true });
|
|
24
|
-
} catch (error) {
|
|
25
|
-
if (error.code !== "EEXIST") {
|
|
26
|
-
throw error;
|
|
27
|
-
}
|
|
28
|
-
const fileInfo = node_fs.lstatSync(directory);
|
|
29
|
-
if (!fileInfo.isDirectory()) {
|
|
30
|
-
throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType.getFileInfoType(fileInfo)}'`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}, "ensureDirSync");
|
|
34
|
-
|
|
35
|
-
module.exports = ensureDirSync;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { lstatSync, mkdirSync } from 'node:fs';
|
|
2
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
|
|
3
|
-
import { g as getFileInfoType } from './get-file-info-type-ButUVD6d.mjs';
|
|
4
|
-
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
-
const ensureDirSync = /* @__PURE__ */ __name((directory) => {
|
|
8
|
-
assertValidFileOrDirectoryPath(directory);
|
|
9
|
-
try {
|
|
10
|
-
const fileInfo = lstatSync(directory);
|
|
11
|
-
if (!fileInfo.isDirectory()) {
|
|
12
|
-
throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
|
|
13
|
-
}
|
|
14
|
-
return;
|
|
15
|
-
} catch (error) {
|
|
16
|
-
if (error.code !== "ENOENT") {
|
|
17
|
-
throw error;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
mkdirSync(directory, { recursive: true });
|
|
22
|
-
} catch (error) {
|
|
23
|
-
if (error.code !== "EEXIST") {
|
|
24
|
-
throw error;
|
|
25
|
-
}
|
|
26
|
-
const fileInfo = lstatSync(directory);
|
|
27
|
-
if (!fileInfo.isDirectory()) {
|
|
28
|
-
throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}, "ensureDirSync");
|
|
32
|
-
|
|
33
|
-
export { ensureDirSync as default };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { lstat, writeFile } from 'node:fs/promises';
|
|
2
|
-
import { dirname } from '@visulima/path';
|
|
3
|
-
import { toPath } from '@visulima/path/utils';
|
|
4
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
|
|
5
|
-
import ensureDir from './ensureDir-BnA_fY1A.mjs';
|
|
6
|
-
import { g as getFileInfoType } from './get-file-info-type-ButUVD6d.mjs';
|
|
7
|
-
|
|
8
|
-
var __defProp = Object.defineProperty;
|
|
9
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
-
const ensureFile = /* @__PURE__ */ __name(async (filePath) => {
|
|
11
|
-
assertValidFileOrDirectoryPath(filePath);
|
|
12
|
-
try {
|
|
13
|
-
const stat = await lstat(filePath);
|
|
14
|
-
if (!stat.isFile()) {
|
|
15
|
-
throw new Error(`Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`);
|
|
16
|
-
}
|
|
17
|
-
} catch (error) {
|
|
18
|
-
if (error.code === "ENOENT") {
|
|
19
|
-
await ensureDir(dirname(toPath(filePath)));
|
|
20
|
-
await writeFile(filePath, new Uint8Array());
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
throw error;
|
|
24
|
-
}
|
|
25
|
-
}, "ensureFile");
|
|
26
|
-
|
|
27
|
-
export { ensureFile as default };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const promises = require('node:fs/promises');
|
|
4
|
-
const path = require('@visulima/path');
|
|
5
|
-
const utils = require('@visulima/path/utils');
|
|
6
|
-
const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs');
|
|
7
|
-
const ensureDir = require('./ensureDir-BOfUZlxG.cjs');
|
|
8
|
-
const getFileInfoType = require('./get-file-info-type-BlryFnpp.cjs');
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
12
|
-
const ensureFile = /* @__PURE__ */ __name(async (filePath) => {
|
|
13
|
-
assertValidFileOrDirectoryPath(filePath);
|
|
14
|
-
try {
|
|
15
|
-
const stat = await promises.lstat(filePath);
|
|
16
|
-
if (!stat.isFile()) {
|
|
17
|
-
throw new Error(`Ensure path exists, expected 'file', got '${getFileInfoType.getFileInfoType(stat)}'`);
|
|
18
|
-
}
|
|
19
|
-
} catch (error) {
|
|
20
|
-
if (error.code === "ENOENT") {
|
|
21
|
-
await ensureDir(path.dirname(utils.toPath(filePath)));
|
|
22
|
-
await promises.writeFile(filePath, new Uint8Array());
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
27
|
-
}, "ensureFile");
|
|
28
|
-
|
|
29
|
-
module.exports = ensureFile;
|
|
@@ -1,29 +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
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
12
|
-
const ensureFileSync = /* @__PURE__ */ __name((filePath) => {
|
|
13
|
-
assertValidFileOrDirectoryPath(filePath);
|
|
14
|
-
try {
|
|
15
|
-
const stat = node_fs.lstatSync(filePath);
|
|
16
|
-
if (!stat.isFile()) {
|
|
17
|
-
throw new Error(`Ensure path exists, expected 'file', got '${getFileInfoType.getFileInfoType(stat)}'`);
|
|
18
|
-
}
|
|
19
|
-
} catch (error) {
|
|
20
|
-
if (error.code === "ENOENT") {
|
|
21
|
-
ensureDirSync(path.dirname(utils.toPath(filePath)));
|
|
22
|
-
node_fs.writeFileSync(filePath, new Uint8Array());
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
27
|
-
}, "ensureFileSync");
|
|
28
|
-
|
|
29
|
-
module.exports = ensureFileSync;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { lstatSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { dirname } from '@visulima/path';
|
|
3
|
-
import { toPath } from '@visulima/path/utils';
|
|
4
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
|
|
5
|
-
import ensureDirSync from './ensureDirSync-Dm4az3YF.mjs';
|
|
6
|
-
import { g as getFileInfoType } from './get-file-info-type-ButUVD6d.mjs';
|
|
7
|
-
|
|
8
|
-
var __defProp = Object.defineProperty;
|
|
9
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
-
const ensureFileSync = /* @__PURE__ */ __name((filePath) => {
|
|
11
|
-
assertValidFileOrDirectoryPath(filePath);
|
|
12
|
-
try {
|
|
13
|
-
const stat = lstatSync(filePath);
|
|
14
|
-
if (!stat.isFile()) {
|
|
15
|
-
throw new Error(`Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`);
|
|
16
|
-
}
|
|
17
|
-
} catch (error) {
|
|
18
|
-
if (error.code === "ENOENT") {
|
|
19
|
-
ensureDirSync(dirname(toPath(filePath)));
|
|
20
|
-
writeFileSync(filePath, new Uint8Array());
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
throw error;
|
|
24
|
-
}
|
|
25
|
-
}, "ensureFileSync");
|
|
26
|
-
|
|
27
|
-
export { ensureFileSync as default };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { lstat, link } from 'node:fs/promises';
|
|
2
|
-
import { toNamespacedPath, dirname } from '@visulima/path';
|
|
3
|
-
import { toPath } from '@visulima/path/utils';
|
|
4
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
|
|
5
|
-
import ensureDir from './ensureDir-BnA_fY1A.mjs';
|
|
6
|
-
import { i as isStatsIdentical } from './is-stats-identical-ByTYZ2Aw.mjs';
|
|
7
|
-
|
|
8
|
-
var __defProp = Object.defineProperty;
|
|
9
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
-
const ensureLink = /* @__PURE__ */ __name(async (source, destination) => {
|
|
11
|
-
assertValidFileOrDirectoryPath(source);
|
|
12
|
-
assertValidFileOrDirectoryPath(destination);
|
|
13
|
-
source = toNamespacedPath(toPath(source));
|
|
14
|
-
destination = toNamespacedPath(toPath(destination));
|
|
15
|
-
let destinationStat;
|
|
16
|
-
try {
|
|
17
|
-
destinationStat = await lstat(destination);
|
|
18
|
-
} catch {
|
|
19
|
-
}
|
|
20
|
-
let sourceStat;
|
|
21
|
-
try {
|
|
22
|
-
sourceStat = await lstat(source);
|
|
23
|
-
} catch (error) {
|
|
24
|
-
error.message = error.message.replace("lstat", "ensureLink");
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
27
|
-
if (destinationStat && isStatsIdentical(sourceStat, destinationStat)) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
await ensureDir(dirname(destination));
|
|
31
|
-
await link(source, destination);
|
|
32
|
-
}, "ensureLink");
|
|
33
|
-
|
|
34
|
-
export { ensureLink as default };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const promises = require('node:fs/promises');
|
|
4
|
-
const path = require('@visulima/path');
|
|
5
|
-
const utils = require('@visulima/path/utils');
|
|
6
|
-
const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs');
|
|
7
|
-
const ensureDir = require('./ensureDir-BOfUZlxG.cjs');
|
|
8
|
-
const isStatsIdentical = require('./is-stats-identical-BfdEfO6i.cjs');
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
12
|
-
const ensureLink = /* @__PURE__ */ __name(async (source, destination) => {
|
|
13
|
-
assertValidFileOrDirectoryPath(source);
|
|
14
|
-
assertValidFileOrDirectoryPath(destination);
|
|
15
|
-
source = path.toNamespacedPath(utils.toPath(source));
|
|
16
|
-
destination = path.toNamespacedPath(utils.toPath(destination));
|
|
17
|
-
let destinationStat;
|
|
18
|
-
try {
|
|
19
|
-
destinationStat = await promises.lstat(destination);
|
|
20
|
-
} catch {
|
|
21
|
-
}
|
|
22
|
-
let sourceStat;
|
|
23
|
-
try {
|
|
24
|
-
sourceStat = await promises.lstat(source);
|
|
25
|
-
} catch (error) {
|
|
26
|
-
error.message = error.message.replace("lstat", "ensureLink");
|
|
27
|
-
throw error;
|
|
28
|
-
}
|
|
29
|
-
if (destinationStat && isStatsIdentical.isStatsIdentical(sourceStat, destinationStat)) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
await ensureDir(path.dirname(destination));
|
|
33
|
-
await promises.link(source, destination);
|
|
34
|
-
}, "ensureLink");
|
|
35
|
-
|
|
36
|
-
module.exports = ensureLink;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { lstatSync, linkSync } from 'node:fs';
|
|
2
|
-
import { toNamespacedPath, dirname } from '@visulima/path';
|
|
3
|
-
import { toPath } from '@visulima/path/utils';
|
|
4
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
|
|
5
|
-
import ensureDirSync from './ensureDirSync-Dm4az3YF.mjs';
|
|
6
|
-
import { i as isStatsIdentical } from './is-stats-identical-ByTYZ2Aw.mjs';
|
|
7
|
-
|
|
8
|
-
var __defProp = Object.defineProperty;
|
|
9
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
-
const ensureLinkSync = /* @__PURE__ */ __name((source, destination) => {
|
|
11
|
-
assertValidFileOrDirectoryPath(source);
|
|
12
|
-
assertValidFileOrDirectoryPath(destination);
|
|
13
|
-
source = toNamespacedPath(toPath(source));
|
|
14
|
-
destination = toNamespacedPath(toPath(destination));
|
|
15
|
-
let destinationStat;
|
|
16
|
-
try {
|
|
17
|
-
destinationStat = lstatSync(destination);
|
|
18
|
-
} catch {
|
|
19
|
-
}
|
|
20
|
-
let sourceStat;
|
|
21
|
-
try {
|
|
22
|
-
sourceStat = lstatSync(source);
|
|
23
|
-
} catch (error) {
|
|
24
|
-
error.message = error.message.replace("lstat", "ensureLink");
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
27
|
-
if (destinationStat && isStatsIdentical(sourceStat, destinationStat)) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
ensureDirSync(dirname(destination));
|
|
31
|
-
linkSync(source, destination);
|
|
32
|
-
}, "ensureLinkSync");
|
|
33
|
-
|
|
34
|
-
export { ensureLinkSync as default };
|
|
@@ -1,36 +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 isStatsIdentical = require('./is-stats-identical-BfdEfO6i.cjs');
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
12
|
-
const ensureLinkSync = /* @__PURE__ */ __name((source, destination) => {
|
|
13
|
-
assertValidFileOrDirectoryPath(source);
|
|
14
|
-
assertValidFileOrDirectoryPath(destination);
|
|
15
|
-
source = path.toNamespacedPath(utils.toPath(source));
|
|
16
|
-
destination = path.toNamespacedPath(utils.toPath(destination));
|
|
17
|
-
let destinationStat;
|
|
18
|
-
try {
|
|
19
|
-
destinationStat = node_fs.lstatSync(destination);
|
|
20
|
-
} catch {
|
|
21
|
-
}
|
|
22
|
-
let sourceStat;
|
|
23
|
-
try {
|
|
24
|
-
sourceStat = node_fs.lstatSync(source);
|
|
25
|
-
} catch (error) {
|
|
26
|
-
error.message = error.message.replace("lstat", "ensureLink");
|
|
27
|
-
throw error;
|
|
28
|
-
}
|
|
29
|
-
if (destinationStat && isStatsIdentical.isStatsIdentical(sourceStat, destinationStat)) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
ensureDirSync(path.dirname(destination));
|
|
33
|
-
node_fs.linkSync(source, destination);
|
|
34
|
-
}, "ensureLinkSync");
|
|
35
|
-
|
|
36
|
-
module.exports = ensureLinkSync;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { lstat, stat, symlink, readlink } from 'node:fs/promises';
|
|
2
|
-
import { toNamespacedPath, dirname, resolve } from '@visulima/path';
|
|
3
|
-
import { toPath } from '@visulima/path/utils';
|
|
4
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
|
|
5
|
-
import ensureDir from './ensureDir-BnA_fY1A.mjs';
|
|
6
|
-
import { g as getFileInfoType } from './get-file-info-type-ButUVD6d.mjs';
|
|
7
|
-
import { i as isStatsIdentical } from './is-stats-identical-ByTYZ2Aw.mjs';
|
|
8
|
-
import { r as resolveSymlinkTarget } from './resolve-symlink-target-BbpEHdU2.mjs';
|
|
9
|
-
import AlreadyExistsError from './AlreadyExistsError-GK7J9fVA.mjs';
|
|
10
|
-
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
-
const isWindows = process.platform === "win32" || /^(?:msys|cygwin)$/.test(process.env.OSTYPE);
|
|
14
|
-
const ensureSymlink = /* @__PURE__ */ __name(async (target, linkName, type) => {
|
|
15
|
-
assertValidFileOrDirectoryPath(target);
|
|
16
|
-
assertValidFileOrDirectoryPath(linkName);
|
|
17
|
-
const targetRealPath = resolveSymlinkTarget(target, linkName);
|
|
18
|
-
linkName = toNamespacedPath(toPath(linkName));
|
|
19
|
-
try {
|
|
20
|
-
const linkStatInfo = await lstat(linkName);
|
|
21
|
-
if (linkStatInfo.isSymbolicLink() && // eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
22
|
-
isStatsIdentical(await stat(targetRealPath), await stat(linkName))) {
|
|
23
|
-
const [sourceStat, destinationStat] = await Promise.all([stat(targetRealPath), stat(linkName)]);
|
|
24
|
-
if (isStatsIdentical(sourceStat, destinationStat)) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
} catch {
|
|
29
|
-
}
|
|
30
|
-
const sourceStatInfo = await lstat(targetRealPath);
|
|
31
|
-
const sourceFilePathType = getFileInfoType(sourceStatInfo);
|
|
32
|
-
await ensureDir(dirname(linkName));
|
|
33
|
-
const symlinkType = type ?? (isWindows ? "junction" : sourceFilePathType === "dir" ? "dir" : "file");
|
|
34
|
-
try {
|
|
35
|
-
await symlink(toNamespacedPath(toPath(targetRealPath)), linkName, symlinkType);
|
|
36
|
-
} catch (error) {
|
|
37
|
-
if (error.code !== "EEXIST") {
|
|
38
|
-
throw error;
|
|
39
|
-
}
|
|
40
|
-
const linkStatInfo = await lstat(linkName);
|
|
41
|
-
if (!linkStatInfo.isSymbolicLink()) {
|
|
42
|
-
throw new AlreadyExistsError("A " + getFileInfoType(linkStatInfo) + " already exists at the path: " + linkName);
|
|
43
|
-
}
|
|
44
|
-
const linkPath = await readlink(linkName);
|
|
45
|
-
const linkRealPath = toNamespacedPath(resolve(linkPath));
|
|
46
|
-
if (linkRealPath !== targetRealPath) {
|
|
47
|
-
throw new AlreadyExistsError("A symlink targeting to an undesired path already exists: " + linkName + " -> " + linkRealPath);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}, "ensureSymlink");
|
|
51
|
-
|
|
52
|
-
export { ensureSymlink as default };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const promises = require('node:fs/promises');
|
|
4
|
-
const path = require('@visulima/path');
|
|
5
|
-
const utils = require('@visulima/path/utils');
|
|
6
|
-
const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs');
|
|
7
|
-
const ensureDir = require('./ensureDir-BOfUZlxG.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 ensureSymlink = /* @__PURE__ */ __name(async (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 = await promises.lstat(linkName);
|
|
23
|
-
if (linkStatInfo.isSymbolicLink() && // eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
24
|
-
isStatsIdentical.isStatsIdentical(await promises.stat(targetRealPath), await promises.stat(linkName))) {
|
|
25
|
-
const [sourceStat, destinationStat] = await Promise.all([promises.stat(targetRealPath), promises.stat(linkName)]);
|
|
26
|
-
if (isStatsIdentical.isStatsIdentical(sourceStat, destinationStat)) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
} catch {
|
|
31
|
-
}
|
|
32
|
-
const sourceStatInfo = await promises.lstat(targetRealPath);
|
|
33
|
-
const sourceFilePathType = getFileInfoType.getFileInfoType(sourceStatInfo);
|
|
34
|
-
await ensureDir(path.dirname(linkName));
|
|
35
|
-
const symlinkType = type ?? (isWindows ? "junction" : sourceFilePathType === "dir" ? "dir" : "file");
|
|
36
|
-
try {
|
|
37
|
-
await promises.symlink(path.toNamespacedPath(utils.toPath(targetRealPath)), linkName, symlinkType);
|
|
38
|
-
} catch (error) {
|
|
39
|
-
if (error.code !== "EEXIST") {
|
|
40
|
-
throw error;
|
|
41
|
-
}
|
|
42
|
-
const linkStatInfo = await promises.lstat(linkName);
|
|
43
|
-
if (!linkStatInfo.isSymbolicLink()) {
|
|
44
|
-
throw new AlreadyExistsError("A " + getFileInfoType.getFileInfoType(linkStatInfo) + " already exists at the path: " + linkName);
|
|
45
|
-
}
|
|
46
|
-
const linkPath = await promises.readlink(linkName);
|
|
47
|
-
const linkRealPath = path.toNamespacedPath(path.resolve(linkPath));
|
|
48
|
-
if (linkRealPath !== targetRealPath) {
|
|
49
|
-
throw new AlreadyExistsError("A symlink targeting to an undesired path already exists: " + linkName + " -> " + linkRealPath);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}, "ensureSymlink");
|
|
53
|
-
|
|
54
|
-
module.exports = ensureSymlink;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { lstatSync, statSync, symlinkSync, readlinkSync } from 'node:fs';
|
|
2
|
-
import { toNamespacedPath, dirname, resolve } from '@visulima/path';
|
|
3
|
-
import { toPath } from '@visulima/path/utils';
|
|
4
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
|
|
5
|
-
import ensureDirSync from './ensureDirSync-Dm4az3YF.mjs';
|
|
6
|
-
import { g as getFileInfoType } from './get-file-info-type-ButUVD6d.mjs';
|
|
7
|
-
import { i as isStatsIdentical } from './is-stats-identical-ByTYZ2Aw.mjs';
|
|
8
|
-
import { r as resolveSymlinkTarget } from './resolve-symlink-target-BbpEHdU2.mjs';
|
|
9
|
-
import AlreadyExistsError from './AlreadyExistsError-GK7J9fVA.mjs';
|
|
10
|
-
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
-
const isWindows = process.platform === "win32" || /^(?:msys|cygwin)$/.test(process.env.OSTYPE);
|
|
14
|
-
const ensureSymlinkSync = /* @__PURE__ */ __name((target, linkName, type) => {
|
|
15
|
-
assertValidFileOrDirectoryPath(target);
|
|
16
|
-
assertValidFileOrDirectoryPath(linkName);
|
|
17
|
-
const targetRealPath = resolveSymlinkTarget(target, linkName);
|
|
18
|
-
linkName = toNamespacedPath(toPath(linkName));
|
|
19
|
-
try {
|
|
20
|
-
const linkStatInfo = lstatSync(linkName);
|
|
21
|
-
if (linkStatInfo.isSymbolicLink() && // eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
22
|
-
isStatsIdentical(statSync(targetRealPath), statSync(linkName))) {
|
|
23
|
-
const sourceStat = statSync(targetRealPath);
|
|
24
|
-
const destinationStat = statSync(linkName);
|
|
25
|
-
if (isStatsIdentical(sourceStat, destinationStat)) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
} catch {
|
|
30
|
-
}
|
|
31
|
-
const sourceStatInfo = lstatSync(targetRealPath);
|
|
32
|
-
const sourceFilePathType = getFileInfoType(sourceStatInfo);
|
|
33
|
-
ensureDirSync(dirname(linkName));
|
|
34
|
-
const symlinkType = type ?? (isWindows ? "junction" : sourceFilePathType === "dir" ? "dir" : "file");
|
|
35
|
-
try {
|
|
36
|
-
symlinkSync(toNamespacedPath(toPath(targetRealPath)), linkName, symlinkType);
|
|
37
|
-
} catch (error) {
|
|
38
|
-
if (error.code !== "EEXIST") {
|
|
39
|
-
throw error;
|
|
40
|
-
}
|
|
41
|
-
const linkStatInfo = lstatSync(linkName);
|
|
42
|
-
if (!linkStatInfo.isSymbolicLink()) {
|
|
43
|
-
throw new AlreadyExistsError("A " + getFileInfoType(linkStatInfo) + " already exists at the path: " + linkName);
|
|
44
|
-
}
|
|
45
|
-
const linkPath = readlinkSync(linkName);
|
|
46
|
-
const linkRealPath = toNamespacedPath(resolve(linkPath));
|
|
47
|
-
if (linkRealPath !== targetRealPath) {
|
|
48
|
-
throw new AlreadyExistsError(
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
|
50
|
-
"A symlink targeting to an undesired path already exists: " + linkName + " -> " + linkRealPath
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}, "ensureSymlinkSync");
|
|
55
|
-
|
|
56
|
-
export { ensureSymlinkSync as default };
|