@visulima/fs 5.0.0-alpha.13 → 5.0.0-alpha.15
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 +23 -0
- package/LICENSE.md +30 -0
- package/dist/eol.js +3 -26
- package/dist/error.js +1 -7
- package/dist/glob-parent.js +1 -90
- package/dist/glob.d.ts +2 -2
- package/dist/glob.js +1 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -38
- package/dist/ini.d.ts +2 -2
- package/dist/ini.js +1 -4
- package/dist/is-glob.js +1 -9
- package/dist/json5.d.ts +2 -2
- package/dist/json5.js +1 -4
- package/dist/jsonc.d.ts +2 -2
- package/dist/jsonc.js +1 -4
- package/dist/match.d.ts +1 -1
- package/dist/match.js +1 -15
- package/dist/packem_shared/AlreadyExistsError-CEu6_Tjb.js +1 -0
- package/dist/packem_shared/DirectoryError-ddlbUV8C.js +1 -0
- package/dist/packem_shared/F_OK-CAwY1qU7.js +1 -0
- package/dist/packem_shared/JSONError-D7h6PNWc.js +4 -0
- package/dist/packem_shared/NotEmptyError-DMh1o7UL.js +1 -0
- package/dist/packem_shared/NotFoundError-BPiW0icm.js +1 -0
- package/dist/packem_shared/PermissionError-B1Emi5a9.js +1 -0
- package/dist/packem_shared/WalkError-Olmh4908.js +1 -0
- package/dist/packem_shared/_commonjsHelpers-D6W6KoPK.js +1 -0
- package/dist/packem_shared/assertValidFileContents-BZFnXa7K.js +1 -0
- package/dist/packem_shared/assertValidFileOrDirectoryPath-DgPIPmZT.js +1 -0
- package/dist/packem_shared/build-rm-options-C1R4reBu.js +1 -0
- package/dist/packem_shared/collect-2KPTpCdX.js +1 -0
- package/dist/packem_shared/collectSync-BX55r_BH.js +1 -0
- package/dist/packem_shared/emptyDir-8utO028L.js +1 -0
- package/dist/packem_shared/emptyDirSync-Bk5fUX73.js +1 -0
- package/dist/packem_shared/ensureDir-CZ4oUFuo.js +1 -0
- package/dist/packem_shared/ensureDirSync-CoPWhbjM.js +1 -0
- package/dist/packem_shared/ensureFile-CF1cAAyh.js +1 -0
- package/dist/packem_shared/ensureFileSync-C3qR6naU.js +1 -0
- package/dist/packem_shared/ensureLink-LLLxlGHn.js +1 -0
- package/dist/packem_shared/ensureLinkSync-Dh_GtT8F.js +1 -0
- package/dist/packem_shared/ensureSymlink-D50kj2zl.js +1 -0
- package/dist/packem_shared/ensureSymlinkSync-BbVDPvI4.js +1 -0
- package/dist/packem_shared/findUp-BT07y_Me.js +1 -0
- package/dist/packem_shared/findUpSync-BvZiYsKJ.js +1 -0
- package/dist/packem_shared/get-file-info-type-CaWGXRjY.js +1 -0
- package/dist/packem_shared/glob-MHJQjR39.js +1 -0
- package/dist/packem_shared/{glob-sync.d-Dsxhj3BW.d.ts → glob-sync.d-D2sDeSpa.d.ts} +1 -1
- package/dist/packem_shared/globSync-CwzlELgS.js +1 -0
- package/dist/packem_shared/index-CYIVJA0W.js +1 -0
- package/dist/packem_shared/index-DrapuBsB.js +1 -0
- package/dist/packem_shared/index-K-NNTkpb.js +11 -0
- package/dist/packem_shared/index-yGx8uzZs.js +1 -0
- package/dist/packem_shared/indexToLineColumn-BRSZFC6I-BKj3uzZt.js +6 -0
- package/dist/packem_shared/ini-preserve-CXc_xkpG.js +4 -0
- package/dist/packem_shared/is-stats-identical-CohsLtWy.js +1 -0
- package/dist/packem_shared/isAccessible-CDFxsAAo.js +1 -0
- package/dist/packem_shared/isAccessibleSync-5nzZWgin.js +1 -0
- package/dist/packem_shared/isFsCaseSensitive-CMZVY1A2.js +1 -0
- package/dist/packem_shared/jsonc-merge-CQMjx3Vw.js +2 -0
- package/dist/packem_shared/move-LmP6P9sn.js +1 -0
- package/dist/packem_shared/parseJson-Xx6vHYbv.js +1 -0
- package/dist/packem_shared/readFile-BAVMZg5e.js +1 -0
- package/dist/packem_shared/readFileSync-CGmzMUF2.js +1 -0
- package/dist/packem_shared/readIni-Cfl6HmTS.js +1 -0
- package/dist/packem_shared/readIniSync-DPg4UD0P.js +1 -0
- package/dist/packem_shared/readJson-kPx68Wv1.js +1 -0
- package/dist/packem_shared/readJson5-pXTL9nUE.js +1 -0
- package/dist/packem_shared/readJson5Sync-BedQc292.js +1 -0
- package/dist/packem_shared/readJsonSync-_HXNI3Se.js +1 -0
- package/dist/packem_shared/readJsonc-BzvuAXbT.js +1 -0
- package/dist/packem_shared/readJsoncSync-CVG1_QnX.js +1 -0
- package/dist/packem_shared/readToml-BO5CZK2P.js +1 -0
- package/dist/packem_shared/readTomlSync-1fKo0R52.js +1 -0
- package/dist/packem_shared/readYaml-DjK_Vqj1.js +1 -0
- package/dist/packem_shared/readYamlSync-C3h6KA2c.js +1 -0
- package/dist/packem_shared/remove-DH41Ov_c.js +1 -0
- package/dist/packem_shared/removeSync-50OEdnHd.js +1 -0
- package/dist/packem_shared/resolve-symlink-target-BofZSDIc.js +1 -0
- package/dist/packem_shared/sanitize-CU1xmyrg.js +1 -0
- package/dist/packem_shared/stripJsonComments-CzNR77MF.js +1 -0
- package/dist/packem_shared/to-uint-8-array-DwgaTasY.js +1 -0
- package/dist/packem_shared/{types.d-CixEXeyM.d.ts → types.d-DjZtAjkJ.d.ts} +26 -26
- package/dist/packem_shared/walk-D01Qmmvz.js +1 -0
- package/dist/packem_shared/walk-include-DCiVAwMP.js +1 -0
- package/dist/packem_shared/walkSync-BknSdmKD.js +1 -0
- package/dist/packem_shared/writeFile-DNGaDOMX.js +1 -0
- package/dist/packem_shared/writeFileSync-CE1i-eMA.js +1 -0
- package/dist/packem_shared/writeIni-DG7U4ji0.js +4 -0
- package/dist/packem_shared/writeIniSync-Ldt6HFLb.js +4 -0
- package/dist/packem_shared/writeJson-BkGlq1Kv.js +4 -0
- package/dist/packem_shared/writeJson5-Btud4sQh.js +4 -0
- package/dist/packem_shared/writeJson5Sync-Iln3i1IV.js +4 -0
- package/dist/packem_shared/writeJsonSync-HndmyvEK.js +4 -0
- package/dist/packem_shared/writeJsonc-9oiamG16.js +4 -0
- package/dist/packem_shared/writeJsoncSync-BHBziPiK.js +4 -0
- package/dist/packem_shared/writeToml-Cj57wZ8B.js +1 -0
- package/dist/packem_shared/writeTomlSync-B34ZZp0e.js +1 -0
- package/dist/packem_shared/writeYaml-BhQX2yN9.js +1 -0
- package/dist/packem_shared/writeYamlSync-DG01FBeC.js +1 -0
- package/dist/size.js +1 -146
- package/dist/toml.d.ts +1 -1
- package/dist/toml.js +1 -4
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -6
- package/dist/yaml.d.ts +2 -2
- package/dist/yaml.js +1 -4
- package/package.json +22 -22
- package/dist/packem_shared/AlreadyExistsError-6Y9hjgMn.js +0 -27
- package/dist/packem_shared/DirectoryError-BfYPkIYP.js +0 -27
- package/dist/packem_shared/F_OK-MldBaGxb.js +0 -8
- package/dist/packem_shared/JSONError-BkHRnInH.js +0 -26
- package/dist/packem_shared/NotEmptyError-B21RUlVr.js +0 -27
- package/dist/packem_shared/NotFoundError-BIp61X6k.js +0 -27
- package/dist/packem_shared/PermissionError-CjoiJgip.js +0 -27
- package/dist/packem_shared/WalkError-DER5A43G.js +0 -24
- package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +0 -5
- package/dist/packem_shared/assertValidFileContents-BmcLtsGd.js +0 -7
- package/dist/packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js +0 -7
- package/dist/packem_shared/build-rm-options-Cl3VDY4O.js +0 -12
- package/dist/packem_shared/collect-CqQ3eVab.js +0 -14
- package/dist/packem_shared/collectSync-noE08NNv.js +0 -14
- package/dist/packem_shared/emptyDir-DnwENOaV.js +0 -46
- package/dist/packem_shared/emptyDirSync-6WiHBo8a.js +0 -43
- package/dist/packem_shared/ensureDir-DNlPftys.js +0 -53
- package/dist/packem_shared/ensureDirSync-DcPZFMy5.js +0 -53
- package/dist/packem_shared/ensureFile-BRQpUOUM.js +0 -47
- package/dist/packem_shared/ensureFileSync-SBY7A9-C.js +0 -47
- package/dist/packem_shared/ensureLink-DJQeauEn.js +0 -55
- package/dist/packem_shared/ensureLinkSync-D9RVAglV.js +0 -55
- package/dist/packem_shared/ensureSymlink-CoRYDRwr.js +0 -80
- package/dist/packem_shared/ensureSymlinkSync-CFimFlgh.js +0 -81
- package/dist/packem_shared/findUp-YcNLKdfV.js +0 -84
- package/dist/packem_shared/findUpSync-BfA5fheN.js +0 -83
- package/dist/packem_shared/get-file-info-type-FD4-jsyg.js +0 -14
- package/dist/packem_shared/glob-DY8l7izD.js +0 -5
- package/dist/packem_shared/globSync-5P2KJf_g.js +0 -5
- package/dist/packem_shared/index-C8W8sfzP.js +0 -830
- package/dist/packem_shared/index-CHM-in-V.js +0 -100
- package/dist/packem_shared/index-bhgnhm4u.js +0 -167
- package/dist/packem_shared/index-xe4o3cYi.js +0 -1784
- package/dist/packem_shared/indexToLineColumn-BUb0GPKl-BF770uX7.js +0 -171
- package/dist/packem_shared/ini-preserve-Dq_Q_Jgb.js +0 -251
- package/dist/packem_shared/is-stats-identical-D8FxpvQU.js +0 -3
- package/dist/packem_shared/isAccessible-DuVrTNFV.js +0 -38
- package/dist/packem_shared/isAccessibleSync-DI8mM0fA.js +0 -38
- package/dist/packem_shared/isFsCaseSensitive-DunL7Iry.js +0 -62
- package/dist/packem_shared/jsonc-merge-C6jWcfWh.js +0 -72
- package/dist/packem_shared/move-DbpW5_vA.js +0 -134
- package/dist/packem_shared/parseJson-BIp89Xjo.js +0 -63
- package/dist/packem_shared/readFile-Iz7kvCCk.js +0 -65
- package/dist/packem_shared/readFileSync-gm9yfIhh.js +0 -54
- package/dist/packem_shared/readIni-CJ2xfpjB.js +0 -10
- package/dist/packem_shared/readIniSync-9LUjaSSp.js +0 -10
- package/dist/packem_shared/readJson-C_rwm-wq.js +0 -22
- package/dist/packem_shared/readJson5-mBoTZppy.js +0 -15
- package/dist/packem_shared/readJson5Sync-8WS2yUok.js +0 -15
- package/dist/packem_shared/readJsonSync-BMEmCcJ6.js +0 -22
- package/dist/packem_shared/readJsonc-j-OS-APg.js +0 -28
- package/dist/packem_shared/readJsoncSync-Aw6EMlWO.js +0 -16
- package/dist/packem_shared/readToml-B2MHaSes.js +0 -9
- package/dist/packem_shared/readTomlSync-DNbK8NEb.js +0 -9
- package/dist/packem_shared/readYaml-D5q2a0e1.js +0 -10
- package/dist/packem_shared/readYamlSync-BKX-PAfq.js +0 -10
- package/dist/packem_shared/remove-C8_gl3jF.js +0 -39
- package/dist/packem_shared/removeSync-BJR_wTwN.js +0 -39
- package/dist/packem_shared/resolve-symlink-target-Kh4GovFf.js +0 -16
- package/dist/packem_shared/sanitize-BZoLN9Fg.js +0 -205
- package/dist/packem_shared/stripJsonComments-vo4k0mpF.js +0 -19
- package/dist/packem_shared/to-uint-8-array-Dz2nF1y1.js +0 -19
- package/dist/packem_shared/walk-CSZgCuDx.js +0 -124
- package/dist/packem_shared/walk-include-CZco7BvN.js +0 -16
- package/dist/packem_shared/walkSync-C4Cy28xb.js +0 -123
- package/dist/packem_shared/writeFile-B8HX0JIQ.js +0 -81
- package/dist/packem_shared/writeFileSync-DB8vv8xR.js +0 -81
- package/dist/packem_shared/writeIni-i55QrL8y.js +0 -65
- package/dist/packem_shared/writeIniSync-CLqJE5t3.js +0 -64
- package/dist/packem_shared/writeJson-Bo7C2UHw.js +0 -50
- package/dist/packem_shared/writeJson5-vVmHUQOd.js +0 -53
- package/dist/packem_shared/writeJson5Sync-oJ546h5k.js +0 -53
- package/dist/packem_shared/writeJsonSync-BKZ_9Acr.js +0 -50
- package/dist/packem_shared/writeJsonc-BufH_oC5.js +0 -60
- package/dist/packem_shared/writeJsoncSync-DB9be1YL.js +0 -59
- package/dist/packem_shared/writeToml-DgTW_-7F.js +0 -8
- package/dist/packem_shared/writeTomlSync-DiBiE9ja.js +0 -8
- package/dist/packem_shared/writeYaml-BWCOome-.js +0 -24
- package/dist/packem_shared/writeYamlSync-DBVnXmuY.js +0 -24
package/dist/size.js
CHANGED
|
@@ -1,146 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
-
|
|
7
|
-
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
-
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
-
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
-
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
-
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
-
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
-
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
// Fallback to createRequire
|
|
17
|
-
return __cjs_require(module);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
readFileSync,
|
|
22
|
-
statSync,
|
|
23
|
-
existsSync
|
|
24
|
-
} = __cjs_getBuiltinModule("node:fs");
|
|
25
|
-
const {
|
|
26
|
-
readFile
|
|
27
|
-
} = __cjs_getBuiltinModule("node:fs/promises");
|
|
28
|
-
const {
|
|
29
|
-
isAbsolute,
|
|
30
|
-
resolve
|
|
31
|
-
} = __cjs_getBuiltinModule("node:path");
|
|
32
|
-
const {
|
|
33
|
-
Readable
|
|
34
|
-
} = __cjs_getBuiltinModule("node:stream");
|
|
35
|
-
const {
|
|
36
|
-
URL
|
|
37
|
-
} = __cjs_getBuiltinModule("node:url");
|
|
38
|
-
const {
|
|
39
|
-
brotliCompressSync,
|
|
40
|
-
gzipSync,
|
|
41
|
-
createGzip,
|
|
42
|
-
createBrotliCompress
|
|
43
|
-
} = __cjs_getBuiltinModule("node:zlib");
|
|
44
|
-
import { toPath } from '@visulima/path/utils';
|
|
45
|
-
|
|
46
|
-
const fileExists = (input) => {
|
|
47
|
-
if (isAbsolute(input)) {
|
|
48
|
-
return existsSync(input);
|
|
49
|
-
}
|
|
50
|
-
try {
|
|
51
|
-
return existsSync(resolve(input));
|
|
52
|
-
} catch {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const getStreamSizeEfficient = async (stream) => {
|
|
57
|
-
let totalSize = 0;
|
|
58
|
-
for await (const chunk of stream) {
|
|
59
|
-
totalSize += Buffer.from(chunk).length;
|
|
60
|
-
}
|
|
61
|
-
return totalSize;
|
|
62
|
-
};
|
|
63
|
-
const getCompressedStreamSizeEfficient = async (stream, createCompressor) => {
|
|
64
|
-
let totalSize = 0;
|
|
65
|
-
const compressor = createCompressor();
|
|
66
|
-
return await new Promise((resolve2, reject) => {
|
|
67
|
-
compressor.on("data", (chunk) => {
|
|
68
|
-
totalSize += chunk.length;
|
|
69
|
-
});
|
|
70
|
-
compressor.on("end", () => {
|
|
71
|
-
resolve2(totalSize);
|
|
72
|
-
});
|
|
73
|
-
compressor.on("error", reject);
|
|
74
|
-
stream.on("error", reject);
|
|
75
|
-
stream.pipe(compressor);
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
const processInputEfficiently = async (input, processor, streamProcessor) => {
|
|
79
|
-
if (input instanceof URL || typeof input === "string") {
|
|
80
|
-
const path = toPath(input);
|
|
81
|
-
if (fileExists(path)) {
|
|
82
|
-
const fileStream = Readable.from(await readFile(path));
|
|
83
|
-
return await streamProcessor(fileStream);
|
|
84
|
-
}
|
|
85
|
-
if (typeof input === "string") {
|
|
86
|
-
return processor(Buffer.from(input));
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (input instanceof Readable) {
|
|
90
|
-
return await streamProcessor(input);
|
|
91
|
-
}
|
|
92
|
-
return processor(input);
|
|
93
|
-
};
|
|
94
|
-
const gzipSize = async (input, options) => {
|
|
95
|
-
const streamProcessor = async (stream) => await getCompressedStreamSizeEfficient(stream, () => createGzip(options));
|
|
96
|
-
const bufferProcessor = (data) => gzipSync(data, options).length;
|
|
97
|
-
return await processInputEfficiently(input, bufferProcessor, streamProcessor);
|
|
98
|
-
};
|
|
99
|
-
const brotliSize = async (input, options) => {
|
|
100
|
-
const streamProcessor = async (stream) => await getCompressedStreamSizeEfficient(stream, () => createBrotliCompress(options));
|
|
101
|
-
const bufferProcessor = (data) => brotliCompressSync(data, options).length;
|
|
102
|
-
return await processInputEfficiently(input, bufferProcessor, streamProcessor);
|
|
103
|
-
};
|
|
104
|
-
const rawSize = async (input) => {
|
|
105
|
-
const streamProcessor = async (stream) => await getStreamSizeEfficient(stream);
|
|
106
|
-
const bufferProcessor = (data) => data.length;
|
|
107
|
-
return await processInputEfficiently(input, bufferProcessor, streamProcessor);
|
|
108
|
-
};
|
|
109
|
-
const gzipSizeSync = (input, options) => {
|
|
110
|
-
if (input instanceof URL || typeof input === "string") {
|
|
111
|
-
const path = toPath(input);
|
|
112
|
-
if (fileExists(path)) {
|
|
113
|
-
return gzipSync(readFileSync(path), options).length;
|
|
114
|
-
}
|
|
115
|
-
if (typeof input === "string") {
|
|
116
|
-
return gzipSync(Buffer.from(input), options).length;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return gzipSync(input, options).length;
|
|
120
|
-
};
|
|
121
|
-
const brotliSizeSync = (input, options) => {
|
|
122
|
-
if (input instanceof URL || typeof input === "string") {
|
|
123
|
-
const path = toPath(input);
|
|
124
|
-
if (fileExists(path)) {
|
|
125
|
-
return brotliCompressSync(readFileSync(path), options).length;
|
|
126
|
-
}
|
|
127
|
-
if (typeof input === "string") {
|
|
128
|
-
return brotliCompressSync(Buffer.from(input), options).length;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return brotliCompressSync(input, options).length;
|
|
132
|
-
};
|
|
133
|
-
const rawSizeSync = (input) => {
|
|
134
|
-
if (input instanceof URL || typeof input === "string") {
|
|
135
|
-
const path = toPath(input);
|
|
136
|
-
if (fileExists(path)) {
|
|
137
|
-
return statSync(path).size;
|
|
138
|
-
}
|
|
139
|
-
if (typeof input === "string") {
|
|
140
|
-
return Buffer.from(input).length;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return input.length;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
export { brotliSize, brotliSizeSync, gzipSize, gzipSizeSync, rawSize, rawSizeSync };
|
|
1
|
+
var w=Object.defineProperty;var p=(e,t)=>w(e,"name",{value:t,configurable:!0});import{createRequire as _}from"node:module";import{toPath as u}from"@visulima/path/utils";const P=_(import.meta.url),s=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,i=p(e=>{if(typeof s<"u"&&s.versions&&s.versions.node){const[t,r]=s.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return s.getBuiltinModule(e)}return P(e)},"__cjs_getBuiltinModule"),{readFileSync:d,statSync:B,existsSync:S}=i("node:fs"),{readFile:v}=i("node:fs/promises"),{isAbsolute:j,resolve:E}=i("node:path"),{Readable:z}=i("node:stream"),{URL:c}=i("node:url"),{brotliCompressSync:a,createBrotliCompress:R,gzipSync:f,createGzip:q}=i("node:zlib");var x=Object.defineProperty,n=p((e,t)=>x(e,"name",{value:t,configurable:!0}),"t");const l=n(e=>{if(j(e))return S(e);try{return S(E(e))}catch{return!1}},"fileExists"),C=n(async e=>{let t=0;for await(const r of e)t+=Buffer.from(r).length;return t},"getStreamSizeEfficient"),h=n(async(e,t)=>{let r=0;const o=t();return await new Promise((g,m)=>{o.on("data",b=>{r+=b.length}),o.on("end",()=>{g(r)}),o.on("error",m),e.on("error",m),e.pipe(o)})},"getCompressedStreamSizeEfficient"),y=n(async(e,t,r)=>{if(e instanceof c||typeof e=="string"){const o=u(e);if(l(o)){const g=z.from(await v(o));return await r(g)}if(typeof e=="string")return t(Buffer.from(e))}return e instanceof z?await r(e):t(e)},"processInputEfficiently"),M=n(async(e,t)=>await y(e,n(r=>f(r,t).length,"bufferProcessor"),n(async r=>await h(r,()=>q(t)),"streamProcessor")),"gzipSize"),A=n(async(e,t)=>await y(e,n(r=>a(r,t).length,"bufferProcessor"),n(async r=>await h(r,()=>R(t)),"streamProcessor")),"brotliSize"),G=n(async e=>await y(e,n(t=>t.length,"bufferProcessor"),n(async t=>await C(t),"streamProcessor")),"rawSize"),L=n((e,t)=>{if(e instanceof c||typeof e=="string"){const r=u(e);if(l(r))return f(d(r),t).length;if(typeof e=="string")return f(Buffer.from(e),t).length}return f(e,t).length},"gzipSizeSync"),N=n((e,t)=>{if(e instanceof c||typeof e=="string"){const r=u(e);if(l(r))return a(d(r),t).length;if(typeof e=="string")return a(Buffer.from(e),t).length}return a(e,t).length},"brotliSizeSync"),O=n(e=>{if(e instanceof c||typeof e=="string"){const t=u(e);if(l(t))return B(t).size;if(typeof e=="string")return Buffer.from(e).length}return e.length},"rawSizeSync");export{A as brotliSize,N as brotliSizeSync,M as gzipSize,L as gzipSizeSync,G as rawSize,O as rawSizeSync};
|
package/dist/toml.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as CompressionType, R as ReadTomlOptions, W as WriteTomlOptions } from "./packem_shared/types.d-DjZtAjkJ.js";
|
|
2
2
|
import 'node:fs';
|
|
3
3
|
import 'tinyglobby';
|
|
4
4
|
/**
|
package/dist/toml.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { default as readTomlSync } from './packem_shared/readTomlSync-DNbK8NEb.js';
|
|
3
|
-
export { default as writeToml } from './packem_shared/writeToml-DgTW_-7F.js';
|
|
4
|
-
export { default as writeTomlSync } from './packem_shared/writeTomlSync-DiBiE9ja.js';
|
|
1
|
+
import{default as r}from"./packem_shared/readToml-BO5CZK2P.js";import{default as t}from"./packem_shared/readTomlSync-1fKo0R52.js";import{default as l}from"./packem_shared/writeToml-Cj57wZ8B.js";import{default as d}from"./packem_shared/writeTomlSync-B34ZZp0e.js";export{r as readToml,t as readTomlSync,l as writeToml,d as writeTomlSync};
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { J as JSONError } from "./packem_shared/json-error.d-DVILOyHc.js";
|
|
2
2
|
import { JsonValue } from 'type-fest';
|
|
3
|
-
import {
|
|
3
|
+
import { h as CodeFrameOptions, i as JsonReviver } from "./packem_shared/types.d-DjZtAjkJ.js";
|
|
4
4
|
export { toPath } from '@visulima/path/utils';
|
|
5
5
|
import 'node:fs';
|
|
6
6
|
import 'tinyglobby';
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { default as assertValidFileContents } from './packem_shared/assertValidFileContents-BmcLtsGd.js';
|
|
3
|
-
export { default as assertValidFileOrDirectoryPath } from './packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
4
|
-
export { default as parseJson } from './packem_shared/parseJson-BIp89Xjo.js';
|
|
5
|
-
export { default as stripJsonComments } from './packem_shared/stripJsonComments-vo4k0mpF.js';
|
|
6
|
-
export { toPath } from '@visulima/path/utils';
|
|
1
|
+
import{default as e}from"./packem_shared/JSONError-D7h6PNWc.js";import{default as a}from"./packem_shared/assertValidFileContents-BZFnXa7K.js";import{default as f}from"./packem_shared/assertValidFileOrDirectoryPath-DgPIPmZT.js";import{default as m}from"./packem_shared/parseJson-Xx6vHYbv.js";import{default as d}from"./packem_shared/stripJsonComments-CzNR77MF.js";import{toPath as x}from"@visulima/path/utils";export{e as JSONError,a as assertValidFileContents,f as assertValidFileOrDirectoryPath,m as parseJson,d as stripJsonComments,x as toPath};
|
package/dist/yaml.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { type
|
|
1
|
+
import { C as CompressionType, d as ReadYamlOptions, Y as YamlReviver, e as WriteYamlOptions, f as JsonReplacer } from "./packem_shared/types.d-DjZtAjkJ.js";
|
|
2
|
+
export { type g as YamlReplacer } from "./packem_shared/types.d-DjZtAjkJ.js";
|
|
3
3
|
import 'node:fs';
|
|
4
4
|
import 'tinyglobby';
|
|
5
5
|
declare function readYaml<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<CompressionType>): Promise<R>;
|
package/dist/yaml.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { default as readYamlSync } from './packem_shared/readYamlSync-BKX-PAfq.js';
|
|
3
|
-
export { default as writeYaml } from './packem_shared/writeYaml-BWCOome-.js';
|
|
4
|
-
export { default as writeYamlSync } from './packem_shared/writeYamlSync-DBVnXmuY.js';
|
|
1
|
+
import{default as r}from"./packem_shared/readYaml-DjK_Vqj1.js";import{default as f}from"./packem_shared/readYamlSync-C3h6KA2c.js";import{default as m}from"./packem_shared/writeYaml-BhQX2yN9.js";import{default as d}from"./packem_shared/writeYamlSync-DG01FBeC.js";export{r as readYaml,f as readYamlSync,m as writeYaml,d as writeYamlSync};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/fs",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.15",
|
|
4
4
|
"description": "Human friendly file system utilities for Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -63,6 +63,11 @@
|
|
|
63
63
|
"bugs": {
|
|
64
64
|
"url": "https://github.com/visulima/visulima/issues"
|
|
65
65
|
},
|
|
66
|
+
"license": "MIT",
|
|
67
|
+
"author": {
|
|
68
|
+
"name": "Daniel Bannert",
|
|
69
|
+
"email": "d.bannert@anolilab.de"
|
|
70
|
+
},
|
|
66
71
|
"repository": {
|
|
67
72
|
"type": "git",
|
|
68
73
|
"url": "git+https://github.com/visulima/visulima.git",
|
|
@@ -78,13 +83,19 @@
|
|
|
78
83
|
"url": "https://anolilab.com/support"
|
|
79
84
|
}
|
|
80
85
|
],
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
"files": [
|
|
87
|
+
"dist/**",
|
|
88
|
+
"README.md",
|
|
89
|
+
"CHANGELOG.md",
|
|
90
|
+
"LICENSE.md"
|
|
91
|
+
],
|
|
92
|
+
"os": [
|
|
93
|
+
"darwin",
|
|
94
|
+
"linux",
|
|
95
|
+
"win32"
|
|
96
|
+
],
|
|
87
97
|
"type": "module",
|
|
98
|
+
"sideEffects": false,
|
|
88
99
|
"exports": {
|
|
89
100
|
".": {
|
|
90
101
|
"types": "./dist/index.d.ts",
|
|
@@ -144,12 +155,10 @@
|
|
|
144
155
|
},
|
|
145
156
|
"./package.json": "./package.json"
|
|
146
157
|
},
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
|
|
151
|
-
"LICENSE.md"
|
|
152
|
-
],
|
|
158
|
+
"publishConfig": {
|
|
159
|
+
"access": "public",
|
|
160
|
+
"provenance": true
|
|
161
|
+
},
|
|
153
162
|
"dependencies": {
|
|
154
163
|
"@visulima/path": "3.0.0-alpha.10"
|
|
155
164
|
},
|
|
@@ -179,14 +188,5 @@
|
|
|
179
188
|
},
|
|
180
189
|
"engines": {
|
|
181
190
|
"node": "^22.14.0 || >=24.10.0"
|
|
182
|
-
},
|
|
183
|
-
"os": [
|
|
184
|
-
"darwin",
|
|
185
|
-
"linux",
|
|
186
|
-
"win32"
|
|
187
|
-
],
|
|
188
|
-
"publishConfig": {
|
|
189
|
-
"access": "public",
|
|
190
|
-
"provenance": true
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
class AlreadyExistsError extends Error {
|
|
2
|
-
/**
|
|
3
|
-
* Creates a new instance.
|
|
4
|
-
* @param message
|
|
5
|
-
*/
|
|
6
|
-
constructor(message) {
|
|
7
|
-
super(`EEXIST: ${message}`);
|
|
8
|
-
}
|
|
9
|
-
// eslint-disable-next-line class-methods-use-this
|
|
10
|
-
get code() {
|
|
11
|
-
return "EEXIST";
|
|
12
|
-
}
|
|
13
|
-
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
14
|
-
set code(_name) {
|
|
15
|
-
throw new Error("Cannot overwrite code EEXIST");
|
|
16
|
-
}
|
|
17
|
-
// eslint-disable-next-line class-methods-use-this
|
|
18
|
-
get name() {
|
|
19
|
-
return "AlreadyExistsError";
|
|
20
|
-
}
|
|
21
|
-
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
22
|
-
set name(_name) {
|
|
23
|
-
throw new Error("Cannot overwrite name of AlreadyExistsError");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { AlreadyExistsError as default };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
class DirectoryError extends Error {
|
|
2
|
-
/**
|
|
3
|
-
* Creates a new instance.
|
|
4
|
-
* @param message
|
|
5
|
-
*/
|
|
6
|
-
constructor(message) {
|
|
7
|
-
super(`EISDIR: Illegal operation on a directory, ${message}`);
|
|
8
|
-
}
|
|
9
|
-
// eslint-disable-next-line class-methods-use-this
|
|
10
|
-
get code() {
|
|
11
|
-
return "EISDIR";
|
|
12
|
-
}
|
|
13
|
-
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
14
|
-
set code(_name) {
|
|
15
|
-
throw new Error("Cannot overwrite code EISDIR");
|
|
16
|
-
}
|
|
17
|
-
// eslint-disable-next-line class-methods-use-this
|
|
18
|
-
get name() {
|
|
19
|
-
return "DirectoryError";
|
|
20
|
-
}
|
|
21
|
-
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
22
|
-
set name(_name) {
|
|
23
|
-
throw new Error("Cannot overwrite name of DirectoryError");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { DirectoryError as default };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const F_OK = 0;
|
|
2
|
-
const R_OK = 4;
|
|
3
|
-
const W_OK = 2;
|
|
4
|
-
const X_OK = 1;
|
|
5
|
-
const FIND_UP_STOP = /* @__PURE__ */ Symbol("findUpStop");
|
|
6
|
-
const INTERNAL_STRIP_JSON_REGEX = /"(?:[^"\\]|\\.)*"|\/\/[^\r\n]*|\/\*[\s\S]*?\*\//g;
|
|
7
|
-
|
|
8
|
-
export { FIND_UP_STOP, F_OK, INTERNAL_STRIP_JSON_REGEX, R_OK, W_OK, X_OK };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
class JSONError extends Error {
|
|
2
|
-
fileName;
|
|
3
|
-
codeFrame;
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
|
|
5
|
-
name = "JSONError";
|
|
6
|
-
#message;
|
|
7
|
-
/**
|
|
8
|
-
* Creates a new JSONError instance.
|
|
9
|
-
* @param message The primary error message.
|
|
10
|
-
*/
|
|
11
|
-
constructor(message) {
|
|
12
|
-
super();
|
|
13
|
-
this.#message = message;
|
|
14
|
-
}
|
|
15
|
-
get message() {
|
|
16
|
-
return `${this.#message}${this.fileName ? ` in ${this.fileName}` : ""}${this.codeFrame ? `
|
|
17
|
-
|
|
18
|
-
${this.codeFrame}
|
|
19
|
-
` : ""}`;
|
|
20
|
-
}
|
|
21
|
-
set message(message) {
|
|
22
|
-
this.#message = message;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { JSONError as default };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
class NotEmptyError extends Error {
|
|
2
|
-
/**
|
|
3
|
-
* Creates a new instance.
|
|
4
|
-
* @param message
|
|
5
|
-
*/
|
|
6
|
-
constructor(message) {
|
|
7
|
-
super(`ENOTEMPTY: Directory not empty, ${message}`);
|
|
8
|
-
}
|
|
9
|
-
// eslint-disable-next-line class-methods-use-this
|
|
10
|
-
get code() {
|
|
11
|
-
return "ENOTEMPTY";
|
|
12
|
-
}
|
|
13
|
-
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
14
|
-
set code(_name) {
|
|
15
|
-
throw new Error("Cannot overwrite code ENOTEMPTY");
|
|
16
|
-
}
|
|
17
|
-
// eslint-disable-next-line class-methods-use-this
|
|
18
|
-
get name() {
|
|
19
|
-
return "NotEmptyError";
|
|
20
|
-
}
|
|
21
|
-
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
22
|
-
set name(_name) {
|
|
23
|
-
throw new Error("Cannot overwrite name of NotEmptyError");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { NotEmptyError as default };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
class NotFoundError extends Error {
|
|
2
|
-
/**
|
|
3
|
-
* Creates a new instance.
|
|
4
|
-
* @param message
|
|
5
|
-
*/
|
|
6
|
-
constructor(message) {
|
|
7
|
-
super(`ENOENT: ${message}`);
|
|
8
|
-
}
|
|
9
|
-
// eslint-disable-next-line class-methods-use-this
|
|
10
|
-
get code() {
|
|
11
|
-
return "ENOENT";
|
|
12
|
-
}
|
|
13
|
-
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
14
|
-
set code(_name) {
|
|
15
|
-
throw new Error("Cannot overwrite code ENOENT");
|
|
16
|
-
}
|
|
17
|
-
// eslint-disable-next-line class-methods-use-this
|
|
18
|
-
get name() {
|
|
19
|
-
return "NotFoundError";
|
|
20
|
-
}
|
|
21
|
-
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
22
|
-
set name(_name) {
|
|
23
|
-
throw new Error("Cannot overwrite name of NotFoundError");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { NotFoundError as default };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
class PermissionError extends Error {
|
|
2
|
-
/**
|
|
3
|
-
* Creates a new instance.
|
|
4
|
-
* @param message
|
|
5
|
-
*/
|
|
6
|
-
constructor(message) {
|
|
7
|
-
super(`EPERM: Operation not permitted, ${message}`);
|
|
8
|
-
}
|
|
9
|
-
// eslint-disable-next-line class-methods-use-this
|
|
10
|
-
get code() {
|
|
11
|
-
return "EPERM";
|
|
12
|
-
}
|
|
13
|
-
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
14
|
-
set code(_name) {
|
|
15
|
-
throw new Error("Cannot overwrite code EPERM");
|
|
16
|
-
}
|
|
17
|
-
// eslint-disable-next-line class-methods-use-this
|
|
18
|
-
get name() {
|
|
19
|
-
return "PermissionError";
|
|
20
|
-
}
|
|
21
|
-
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
22
|
-
set name(_name) {
|
|
23
|
-
throw new Error("Cannot overwrite name of PermissionError");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { PermissionError as default };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
class WalkError extends Error {
|
|
2
|
-
/** File path of the root that's being walked. */
|
|
3
|
-
root;
|
|
4
|
-
/**
|
|
5
|
-
* Constructs a new instance.
|
|
6
|
-
* @param cause The underlying error or reason for the walk failure.
|
|
7
|
-
* @param root The root directory path where the walk operation started or encountered the error.
|
|
8
|
-
*/
|
|
9
|
-
constructor(cause, root) {
|
|
10
|
-
super(`${cause instanceof Error ? cause.message : String(cause)} for path "${root}"`);
|
|
11
|
-
this.cause = cause;
|
|
12
|
-
this.root = root;
|
|
13
|
-
}
|
|
14
|
-
// eslint-disable-next-line class-methods-use-this
|
|
15
|
-
get name() {
|
|
16
|
-
return "WalkError";
|
|
17
|
-
}
|
|
18
|
-
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/explicit-module-boundary-types
|
|
19
|
-
set name(_name) {
|
|
20
|
-
throw new Error("Cannot overwrite name of WalkError");
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { WalkError as default };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
const assertValidFileContents = (contents) => {
|
|
2
|
-
if (typeof contents !== "string" && !(contents instanceof ArrayBuffer) && !ArrayBuffer.isView(contents)) {
|
|
3
|
-
throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.");
|
|
4
|
-
}
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export { assertValidFileContents as default };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
const assertValidFileOrDirectoryPath = (fileOrDirectoryPath) => {
|
|
2
|
-
if (!fileOrDirectoryPath || !(fileOrDirectoryPath instanceof URL) && typeof fileOrDirectoryPath !== "string") {
|
|
3
|
-
throw new TypeError("Path must be a non-empty string or URL.");
|
|
4
|
-
}
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export { assertValidFileOrDirectoryPath as default };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const buildRmOptions = (options) => {
|
|
2
|
-
const rmOptions = { force: true, recursive: true };
|
|
3
|
-
if (options?.maxRetries !== void 0) {
|
|
4
|
-
rmOptions.maxRetries = options.maxRetries;
|
|
5
|
-
}
|
|
6
|
-
if (options?.retryDelay !== void 0) {
|
|
7
|
-
rmOptions.retryDelay = options.retryDelay;
|
|
8
|
-
}
|
|
9
|
-
return rmOptions;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export { buildRmOptions as b };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import walk from './walk-CSZgCuDx.js';
|
|
2
|
-
|
|
3
|
-
const collect = async (directory, options = {}) => {
|
|
4
|
-
if (!Array.isArray(options.extensions)) {
|
|
5
|
-
options.extensions = ["js", "mjs", "cjs", "ts"];
|
|
6
|
-
}
|
|
7
|
-
const entries = [];
|
|
8
|
-
for await (const entry of walk(directory, options)) {
|
|
9
|
-
entries.push(entry.path);
|
|
10
|
-
}
|
|
11
|
-
return entries;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { collect as default };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import walkSync from './walkSync-C4Cy28xb.js';
|
|
2
|
-
|
|
3
|
-
const collectSync = (directory, options = {}) => {
|
|
4
|
-
if (!Array.isArray(options.extensions)) {
|
|
5
|
-
options.extensions = ["js", "mjs", "cjs", "ts"];
|
|
6
|
-
}
|
|
7
|
-
const entries = [];
|
|
8
|
-
for (const entry of walkSync(directory, options)) {
|
|
9
|
-
entries.push(entry.path);
|
|
10
|
-
}
|
|
11
|
-
return entries;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { collectSync as default };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
-
|
|
7
|
-
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
-
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
-
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
-
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
-
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
-
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
-
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
// Fallback to createRequire
|
|
17
|
-
return __cjs_require(module);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
existsSync
|
|
22
|
-
} = __cjs_getBuiltinModule("node:fs");
|
|
23
|
-
const {
|
|
24
|
-
mkdir,
|
|
25
|
-
readdir,
|
|
26
|
-
rm
|
|
27
|
-
} = __cjs_getBuiltinModule("node:fs/promises");
|
|
28
|
-
import { join } from '@visulima/path';
|
|
29
|
-
import { toPath } from '@visulima/path/utils';
|
|
30
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
31
|
-
import { b as buildRmOptions } from './build-rm-options-Cl3VDY4O.js';
|
|
32
|
-
|
|
33
|
-
const emptyDir = async (dir, options) => {
|
|
34
|
-
assertValidFileOrDirectoryPath(dir);
|
|
35
|
-
if (!existsSync(dir)) {
|
|
36
|
-
await mkdir(dir, { recursive: true });
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const items = await readdir(dir);
|
|
40
|
-
const rmOptions = buildRmOptions(options);
|
|
41
|
-
for (const item of items) {
|
|
42
|
-
await rm(join(toPath(dir), item), rmOptions);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export { emptyDir as default };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
-
|
|
7
|
-
const __cjs_getBuiltinModule = (module) => {
|
|
8
|
-
// Check if we're in Node.js and version supports getBuiltinModule
|
|
9
|
-
if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
|
|
10
|
-
const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
|
|
11
|
-
// Node.js 20.16.0+ and 22.3.0+
|
|
12
|
-
if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
|
|
13
|
-
return __cjs_getProcess.getBuiltinModule(module);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
// Fallback to createRequire
|
|
17
|
-
return __cjs_require(module);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
existsSync,
|
|
22
|
-
mkdirSync,
|
|
23
|
-
readdirSync,
|
|
24
|
-
rmSync
|
|
25
|
-
} = __cjs_getBuiltinModule("node:fs");
|
|
26
|
-
import { join } from '@visulima/path';
|
|
27
|
-
import { toPath } from '@visulima/path/utils';
|
|
28
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
29
|
-
import { b as buildRmOptions } from './build-rm-options-Cl3VDY4O.js';
|
|
30
|
-
|
|
31
|
-
const emptyDirSync = (dir, options) => {
|
|
32
|
-
assertValidFileOrDirectoryPath(dir);
|
|
33
|
-
if (!existsSync(dir)) {
|
|
34
|
-
mkdirSync(dir, { recursive: true });
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const rmOptions = buildRmOptions(options);
|
|
38
|
-
for (const item of readdirSync(dir)) {
|
|
39
|
-
rmSync(join(toPath(dir), item), rmOptions);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export { emptyDirSync as default };
|