@visulima/fs 5.0.0-alpha.2 → 5.0.0-alpha.21
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 +263 -0
- package/LICENSE.md +208 -131
- package/dist/eol.d.ts +31 -30
- package/dist/eol.js +3 -26
- package/dist/error.d.ts +273 -7
- package/dist/error.js +1 -7
- package/dist/glob-parent.d.ts +35 -0
- package/dist/glob-parent.js +1 -0
- package/dist/glob.d.ts +4 -0
- package/dist/glob.js +1 -0
- package/dist/index.d.ts +858 -36
- package/dist/index.js +1 -33
- package/dist/ini.d.ts +70 -0
- package/dist/ini.js +1 -0
- package/dist/is-glob.d.ts +34 -0
- package/dist/is-glob.js +1 -0
- package/dist/json5.d.ts +36 -0
- package/dist/json5.js +1 -0
- package/dist/jsonc.d.ts +65 -0
- package/dist/jsonc.js +1 -0
- package/dist/match.d.ts +46 -0
- package/dist/match.js +1 -0
- 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-ODRbh6wE.d.ts +54 -0
- 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/json-error.d-DVILOyHc.d.ts +52 -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-CHp56oCv.d.ts +1660 -0
- 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.d.ts +246 -246
- package/dist/size.js +1 -144
- package/dist/toml.d.ts +63 -0
- package/dist/toml.js +1 -0
- package/dist/utils.d.ts +103 -6
- package/dist/utils.js +1 -6
- package/dist/yaml.d.ts +13 -5
- package/dist/yaml.js +1 -4
- package/package.json +89 -36
- package/dist/constants.d.ts +0 -42
- package/dist/ensure/ensure-dir-sync.d.ts +0 -14
- package/dist/ensure/ensure-dir.d.ts +0 -14
- package/dist/ensure/ensure-file-sync.d.ts +0 -15
- package/dist/ensure/ensure-file.d.ts +0 -27
- package/dist/ensure/ensure-link-sync.d.ts +0 -16
- package/dist/ensure/ensure-link.d.ts +0 -16
- package/dist/ensure/ensure-symlink-sync.d.ts +0 -23
- package/dist/ensure/ensure-symlink.d.ts +0 -23
- package/dist/ensure/utils/get-file-info-type.d.ts +0 -7
- package/dist/ensure/utils/is-stats-identical.d.ts +0 -3
- package/dist/ensure/utils/resolve-symlink-target.d.ts +0 -2
- package/dist/error/already-exists-error.d.ts +0 -39
- package/dist/error/directory-error.d.ts +0 -47
- package/dist/error/json-error.d.ts +0 -52
- package/dist/error/not-empty-error.d.ts +0 -51
- package/dist/error/not-found-error.d.ts +0 -44
- package/dist/error/permission-error.d.ts +0 -45
- package/dist/error/walk-error.d.ts +0 -51
- package/dist/find/collect-sync.d.ts +0 -31
- package/dist/find/collect.d.ts +0 -35
- package/dist/find/find-up-sync.d.ts +0 -42
- package/dist/find/find-up.d.ts +0 -46
- package/dist/find/utils/glob-to-regexp.d.ts +0 -2
- package/dist/find/utils/walk-include.d.ts +0 -2
- package/dist/find/walk-sync.d.ts +0 -34
- package/dist/find/walk.d.ts +0 -37
- package/dist/is-accessible-sync.d.ts +0 -3
- package/dist/is-accessible.d.ts +0 -29
- package/dist/move/index.d.ts +0 -68
- package/dist/move/types.d.ts +0 -36
- package/dist/move/utils/internal-move-file-sync.d.ts +0 -3
- package/dist/move/utils/internal-move-file.d.ts +0 -3
- package/dist/move/utils/validate-same-directory.d.ts +0 -2
- 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-DUdQd6FT.js +0 -24
- package/dist/packem_shared/assertValidFileContents-BmcLtsGd.js +0 -7
- package/dist/packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js +0 -7
- package/dist/packem_shared/collect-DcBwsYYd.js +0 -14
- package/dist/packem_shared/collectSync-Bkjf9Dbm.js +0 -14
- package/dist/packem_shared/emptyDir-CYB5Tict.js +0 -43
- package/dist/packem_shared/emptyDirSync-BD8-1Ytl.js +0 -41
- package/dist/packem_shared/ensureDir-C_kuQ5Ik.js +0 -53
- package/dist/packem_shared/ensureDirSync-CI5g-uBI.js +0 -53
- package/dist/packem_shared/ensureFile-BUtXGlGT.js +0 -47
- package/dist/packem_shared/ensureFileSync-C8hASR-1.js +0 -47
- package/dist/packem_shared/ensureLink-BPnAG5-P.js +0 -54
- package/dist/packem_shared/ensureLinkSync-B-Z7X0ub.js +0 -54
- package/dist/packem_shared/ensureSymlink-U5B6J0BN.js +0 -73
- package/dist/packem_shared/ensureSymlinkSync-DHnZj-9F.js +0 -74
- package/dist/packem_shared/findUp-BSnyGqer.js +0 -85
- package/dist/packem_shared/findUpSync-jRHbSCMV.js +0 -85
- package/dist/packem_shared/get-file-info-type-FD4-jsyg.js +0 -14
- package/dist/packem_shared/index-CHM-in-V.js +0 -100
- 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-D-ayleCy.js +0 -62
- package/dist/packem_shared/move-DbpW5_vA.js +0 -134
- package/dist/packem_shared/parseJson-C8xb-3LR.js +0 -231
- package/dist/packem_shared/readFile-Iz7kvCCk.js +0 -65
- package/dist/packem_shared/readFileSync-6GEIrOnl.js +0 -53
- package/dist/packem_shared/readJson-vddQ97Ll.js +0 -22
- package/dist/packem_shared/readJsonSync-DzeAdYZl.js +0 -22
- package/dist/packem_shared/readYaml-D5q2a0e1.js +0 -10
- package/dist/packem_shared/readYamlSync-DMV4U-gi.js +0 -10
- package/dist/packem_shared/remove-_oDY3uKo.js +0 -38
- package/dist/packem_shared/removeSync-DETRj7Qn.js +0 -38
- package/dist/packem_shared/resolve-symlink-target-Kh4GovFf.js +0 -16
- package/dist/packem_shared/sanitize-lOzE6k2A.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-BhTbpr3y.js +0 -115
- package/dist/packem_shared/walk-include-CZco7BvN.js +0 -16
- package/dist/packem_shared/walkSync-DDBq95s8.js +0 -114
- package/dist/packem_shared/writeFile-DSHERs0Z.js +0 -83
- package/dist/packem_shared/writeFileSync-CJp1kXQR.js +0 -83
- package/dist/packem_shared/writeJson-C0OfLDbe.js +0 -50
- package/dist/packem_shared/writeJsonSync-Cs21FE7v.js +0 -50
- package/dist/packem_shared/writeYaml-n4xzYN9a.js +0 -24
- package/dist/packem_shared/writeYamlSync-DnOEnP10.js +0 -24
- package/dist/read/read-file-sync.d.ts +0 -37
- package/dist/read/read-file.d.ts +0 -41
- package/dist/read/read-json-sync.d.ts +0 -5
- package/dist/read/read-json.d.ts +0 -5
- package/dist/read/read-yaml-sync.d.ts +0 -4
- package/dist/read/read-yaml.d.ts +0 -4
- package/dist/remove/empty-dir-sync.d.ts +0 -23
- package/dist/remove/empty-dir.d.ts +0 -28
- package/dist/remove/remove-sync.d.ts +0 -27
- package/dist/remove/remove.d.ts +0 -32
- package/dist/sanitize.d.ts +0 -31
- package/dist/types.d.ts +0 -304
- package/dist/utils/assert-valid-file-contents.d.ts +0 -27
- package/dist/utils/assert-valid-file-or-directory-path.d.ts +0 -26
- package/dist/utils/parse-json.d.ts +0 -5
- package/dist/utils/strip-json-comments.d.ts +0 -44
- package/dist/write/utils/to-uint-8-array.d.ts +0 -2
- package/dist/write/write-file-sync.d.ts +0 -30
- package/dist/write/write-file.d.ts +0 -30
- package/dist/write/write-json-sync.d.ts +0 -29
- package/dist/write/write-json.d.ts +0 -30
- package/dist/write/write-yaml-sync.d.ts +0 -4
- package/dist/write/write-yaml.d.ts +0 -4
|
@@ -1,114 +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
|
-
readdirSync,
|
|
22
|
-
realpathSync,
|
|
23
|
-
statSync
|
|
24
|
-
} = __cjs_getBuiltinModule("node:fs");
|
|
25
|
-
import { resolve, join, normalize, basename } from '@visulima/path';
|
|
26
|
-
import { toPath } from '@visulima/path/utils';
|
|
27
|
-
import WalkError from './WalkError-DUdQd6FT.js';
|
|
28
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
29
|
-
import { g as globToRegExp, w as walkInclude } from './walk-include-CZco7BvN.js';
|
|
30
|
-
|
|
31
|
-
const _createWalkEntry = (path) => {
|
|
32
|
-
const normalizePath = normalize(path);
|
|
33
|
-
const info = statSync(normalizePath);
|
|
34
|
-
return {
|
|
35
|
-
isDirectory: info.isDirectory,
|
|
36
|
-
isFile: info.isFile,
|
|
37
|
-
isSymbolicLink: info.isSymbolicLink,
|
|
38
|
-
name: basename(normalizePath),
|
|
39
|
-
path: normalizePath
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
function* walkSync(directory, {
|
|
43
|
-
extensions,
|
|
44
|
-
followSymlinks = false,
|
|
45
|
-
includeDirs: includeDirectories = true,
|
|
46
|
-
includeFiles = true,
|
|
47
|
-
includeSymlinks = true,
|
|
48
|
-
match,
|
|
49
|
-
maxDepth = Number.POSITIVE_INFINITY,
|
|
50
|
-
skip
|
|
51
|
-
} = {}) {
|
|
52
|
-
assertValidFileOrDirectoryPath(directory);
|
|
53
|
-
if (maxDepth < 0) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
const mappedMatch = match ? match.map((pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern) : void 0;
|
|
57
|
-
const mappedSkip = skip ? skip.map((pattern) => typeof pattern === "string" ? globToRegExp(pattern) : pattern) : void 0;
|
|
58
|
-
directory = resolve(toPath(directory));
|
|
59
|
-
if (includeDirectories && walkInclude(directory, extensions, mappedMatch, mappedSkip)) {
|
|
60
|
-
yield _createWalkEntry(directory);
|
|
61
|
-
}
|
|
62
|
-
if (maxDepth < 1 || !walkInclude(directory, void 0, void 0, mappedSkip)) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
for (const entry of readdirSync(directory, {
|
|
67
|
-
withFileTypes: true
|
|
68
|
-
})) {
|
|
69
|
-
let path = join(directory, entry.name);
|
|
70
|
-
if (entry.isSymbolicLink()) {
|
|
71
|
-
if (followSymlinks) {
|
|
72
|
-
path = realpathSync(path);
|
|
73
|
-
} else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {
|
|
74
|
-
yield {
|
|
75
|
-
isDirectory: entry.isDirectory,
|
|
76
|
-
isFile: entry.isFile,
|
|
77
|
-
isSymbolicLink: entry.isSymbolicLink,
|
|
78
|
-
name: entry.name,
|
|
79
|
-
path: normalize(path)
|
|
80
|
-
};
|
|
81
|
-
} else {
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (entry.isSymbolicLink() || entry.isDirectory()) {
|
|
86
|
-
yield* walkSync(path, {
|
|
87
|
-
extensions,
|
|
88
|
-
followSymlinks,
|
|
89
|
-
includeDirs: includeDirectories,
|
|
90
|
-
includeFiles,
|
|
91
|
-
includeSymlinks,
|
|
92
|
-
match: mappedMatch,
|
|
93
|
-
maxDepth: maxDepth - 1,
|
|
94
|
-
skip: mappedSkip
|
|
95
|
-
});
|
|
96
|
-
} else if (entry.isFile() && includeFiles && walkInclude(path, extensions, mappedMatch, mappedSkip)) {
|
|
97
|
-
yield {
|
|
98
|
-
isDirectory: entry.isDirectory,
|
|
99
|
-
isFile: entry.isFile,
|
|
100
|
-
isSymbolicLink: entry.isSymbolicLink,
|
|
101
|
-
name: entry.name,
|
|
102
|
-
path: normalize(path)
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
} catch (error) {
|
|
107
|
-
if (error instanceof WalkError) {
|
|
108
|
-
throw error;
|
|
109
|
-
}
|
|
110
|
-
throw new WalkError(error, directory);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export { walkSync as default };
|
|
@@ -1,83 +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
|
-
mkdir,
|
|
22
|
-
writeFile: writeFile$1,
|
|
23
|
-
stat,
|
|
24
|
-
rename,
|
|
25
|
-
chown,
|
|
26
|
-
chmod,
|
|
27
|
-
unlink
|
|
28
|
-
} = __cjs_getBuiltinModule("node:fs/promises");
|
|
29
|
-
import { dirname } from '@visulima/path';
|
|
30
|
-
import { toPath } from '@visulima/path/utils';
|
|
31
|
-
import { F_OK } from './F_OK-MldBaGxb.js';
|
|
32
|
-
import isAccessible from './isAccessible-DuVrTNFV.js';
|
|
33
|
-
import assertValidFileContents from './assertValidFileContents-BmcLtsGd.js';
|
|
34
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
35
|
-
import { t as toUint8Array } from './to-uint-8-array-Dz2nF1y1.js';
|
|
36
|
-
|
|
37
|
-
const writeFile = async (path, content, options) => {
|
|
38
|
-
options = {
|
|
39
|
-
encoding: "utf8",
|
|
40
|
-
flag: "w",
|
|
41
|
-
overwrite: true,
|
|
42
|
-
recursive: true,
|
|
43
|
-
...options
|
|
44
|
-
};
|
|
45
|
-
assertValidFileOrDirectoryPath(path);
|
|
46
|
-
assertValidFileContents(content);
|
|
47
|
-
path = toPath(path);
|
|
48
|
-
const temporaryPath = `${path}.tmp`;
|
|
49
|
-
try {
|
|
50
|
-
const pathExists = await isAccessible(path, F_OK);
|
|
51
|
-
if (!pathExists && options.recursive) {
|
|
52
|
-
const directory = dirname(path);
|
|
53
|
-
if (!await isAccessible(directory, F_OK)) {
|
|
54
|
-
await mkdir(directory, { recursive: true });
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
let stat$1;
|
|
58
|
-
await writeFile$1(temporaryPath, toUint8Array(content), { encoding: options.encoding, flag: options.flag });
|
|
59
|
-
if (pathExists && !options.overwrite) {
|
|
60
|
-
stat$1 = await stat(path);
|
|
61
|
-
if (options.chown === void 0) {
|
|
62
|
-
options.chown = { gid: stat$1.gid, uid: stat$1.uid };
|
|
63
|
-
}
|
|
64
|
-
await rename(path, `${path}.bak`);
|
|
65
|
-
}
|
|
66
|
-
if (options.chown) {
|
|
67
|
-
try {
|
|
68
|
-
await chown(temporaryPath, options.chown.uid, options.chown.gid);
|
|
69
|
-
} catch {
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
await chmod(temporaryPath, stat$1 && !options.mode ? stat$1.mode : options.mode ?? 438);
|
|
73
|
-
await rename(temporaryPath, path);
|
|
74
|
-
} catch (error) {
|
|
75
|
-
throw new Error(`Failed to write file at: ${path} - ${error.message}`, { cause: error });
|
|
76
|
-
} finally {
|
|
77
|
-
if (await isAccessible(temporaryPath)) {
|
|
78
|
-
await unlink(`${path}.tmp`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export { writeFile as default };
|
|
@@ -1,83 +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
|
-
mkdirSync,
|
|
22
|
-
writeFileSync: writeFileSync$1,
|
|
23
|
-
statSync,
|
|
24
|
-
renameSync,
|
|
25
|
-
chownSync,
|
|
26
|
-
chmodSync,
|
|
27
|
-
unlinkSync
|
|
28
|
-
} = __cjs_getBuiltinModule("node:fs");
|
|
29
|
-
import { dirname } from '@visulima/path';
|
|
30
|
-
import { toPath } from '@visulima/path/utils';
|
|
31
|
-
import { F_OK } from './F_OK-MldBaGxb.js';
|
|
32
|
-
import isAccessibleSync from './isAccessibleSync-DI8mM0fA.js';
|
|
33
|
-
import assertValidFileContents from './assertValidFileContents-BmcLtsGd.js';
|
|
34
|
-
import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
|
|
35
|
-
import { t as toUint8Array } from './to-uint-8-array-Dz2nF1y1.js';
|
|
36
|
-
|
|
37
|
-
const writeFileSync = (path, content, options) => {
|
|
38
|
-
options = {
|
|
39
|
-
encoding: "utf8",
|
|
40
|
-
flag: "w",
|
|
41
|
-
overwrite: true,
|
|
42
|
-
recursive: true,
|
|
43
|
-
...options
|
|
44
|
-
};
|
|
45
|
-
assertValidFileOrDirectoryPath(path);
|
|
46
|
-
assertValidFileContents(content);
|
|
47
|
-
path = toPath(path);
|
|
48
|
-
const temporaryPath = `${path}.tmp`;
|
|
49
|
-
try {
|
|
50
|
-
const pathExists = isAccessibleSync(path, F_OK);
|
|
51
|
-
if (!pathExists && options.recursive) {
|
|
52
|
-
const directory = dirname(path);
|
|
53
|
-
if (!isAccessibleSync(directory, F_OK)) {
|
|
54
|
-
mkdirSync(directory, { recursive: true });
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
let stat;
|
|
58
|
-
writeFileSync$1(temporaryPath, toUint8Array(content), { encoding: options.encoding, flag: options.flag });
|
|
59
|
-
if (pathExists && !options.overwrite) {
|
|
60
|
-
stat = statSync(path);
|
|
61
|
-
if (options.chown === void 0) {
|
|
62
|
-
options.chown = { gid: stat.gid, uid: stat.uid };
|
|
63
|
-
}
|
|
64
|
-
renameSync(path, `${path}.bak`);
|
|
65
|
-
}
|
|
66
|
-
if (options.chown) {
|
|
67
|
-
try {
|
|
68
|
-
chownSync(temporaryPath, options.chown.uid, options.chown.gid);
|
|
69
|
-
} catch {
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
chmodSync(temporaryPath, stat && !options.mode ? stat.mode : options.mode ?? 438);
|
|
73
|
-
renameSync(temporaryPath, path);
|
|
74
|
-
} catch (error) {
|
|
75
|
-
throw new Error(`Failed to write file at: ${path} - ${error.message}`, { cause: error });
|
|
76
|
-
} finally {
|
|
77
|
-
if (isAccessibleSync(temporaryPath)) {
|
|
78
|
-
unlinkSync(`${path}.tmp`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export { writeFileSync as default };
|
|
@@ -1,50 +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
|
-
readFile
|
|
22
|
-
} = __cjs_getBuiltinModule("node:fs/promises");
|
|
23
|
-
import { d as detectIndent } from './index-CHM-in-V.js';
|
|
24
|
-
import { R_OK } from './F_OK-MldBaGxb.js';
|
|
25
|
-
import isAccessible from './isAccessible-DuVrTNFV.js';
|
|
26
|
-
import writeFile from './writeFile-DSHERs0Z.js';
|
|
27
|
-
|
|
28
|
-
const writeJson = async (path, data, options = {}) => {
|
|
29
|
-
const { detectIndent: detectIndent$1, indent: indentOption, replacer, stringify = JSON.stringify, ...writeOptions } = { indent: " ", ...options };
|
|
30
|
-
let indent = indentOption;
|
|
31
|
-
let trailingNewline = "\n";
|
|
32
|
-
if (await isAccessible(path, R_OK)) {
|
|
33
|
-
try {
|
|
34
|
-
const file = await readFile(path, "utf8");
|
|
35
|
-
if (detectIndent$1) {
|
|
36
|
-
const { indent: dIndent } = detectIndent(file);
|
|
37
|
-
indent = dIndent;
|
|
38
|
-
}
|
|
39
|
-
trailingNewline = file.endsWith("\n") ? "\n" : "";
|
|
40
|
-
} catch (error) {
|
|
41
|
-
if (error.code !== "ENOENT") {
|
|
42
|
-
throw error;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const json = stringify(data, replacer, indent);
|
|
47
|
-
await writeFile(path, `${json}${trailingNewline}`, writeOptions);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export { writeJson as default };
|
|
@@ -1,50 +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
|
-
readFileSync
|
|
22
|
-
} = __cjs_getBuiltinModule("node:fs");
|
|
23
|
-
import { d as detectIndent } from './index-CHM-in-V.js';
|
|
24
|
-
import { R_OK } from './F_OK-MldBaGxb.js';
|
|
25
|
-
import isAccessibleSync from './isAccessibleSync-DI8mM0fA.js';
|
|
26
|
-
import writeFileSync from './writeFileSync-CJp1kXQR.js';
|
|
27
|
-
|
|
28
|
-
const writeJsonSync = (path, data, options = {}) => {
|
|
29
|
-
const { detectIndent: detectIndent$1, indent: indentOption, replacer, stringify = JSON.stringify, ...writeOptions } = { indent: " ", ...options };
|
|
30
|
-
let indent = indentOption;
|
|
31
|
-
let trailingNewline = "\n";
|
|
32
|
-
if (isAccessibleSync(path, R_OK)) {
|
|
33
|
-
try {
|
|
34
|
-
const file = readFileSync(path, "utf8");
|
|
35
|
-
if (detectIndent$1) {
|
|
36
|
-
const { indent: dIndent } = detectIndent(file);
|
|
37
|
-
indent = dIndent;
|
|
38
|
-
}
|
|
39
|
-
trailingNewline = file.endsWith("\n") ? "\n" : "";
|
|
40
|
-
} catch (error) {
|
|
41
|
-
if (error.code !== "ENOENT") {
|
|
42
|
-
throw error;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const json = stringify(data, replacer, indent);
|
|
47
|
-
writeFileSync(path, `${json}${trailingNewline}`, writeOptions);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export { writeJsonSync as default };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { stringify } from 'yaml';
|
|
2
|
-
import writeFile from './writeFile-DSHERs0Z.js';
|
|
3
|
-
|
|
4
|
-
async function writeYaml(path, data, replacer, options) {
|
|
5
|
-
let stringifyOptions;
|
|
6
|
-
let effectiveReplacer;
|
|
7
|
-
let space;
|
|
8
|
-
if (typeof replacer === "object" && replacer !== null && !Array.isArray(replacer) && typeof replacer !== "function") {
|
|
9
|
-
stringifyOptions = replacer;
|
|
10
|
-
effectiveReplacer = stringifyOptions.replacer;
|
|
11
|
-
space = stringifyOptions.space;
|
|
12
|
-
} else if (typeof options === "object" && options !== null) {
|
|
13
|
-
stringifyOptions = options;
|
|
14
|
-
effectiveReplacer = replacer;
|
|
15
|
-
space = stringifyOptions.space ?? (typeof options === "number" || typeof options === "string" ? options : void 0);
|
|
16
|
-
} else {
|
|
17
|
-
effectiveReplacer = replacer;
|
|
18
|
-
space = options;
|
|
19
|
-
}
|
|
20
|
-
const content = stringify(data, effectiveReplacer, space ?? stringifyOptions);
|
|
21
|
-
await writeFile(path, content, stringifyOptions);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { writeYaml as default };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { stringify } from 'yaml';
|
|
2
|
-
import writeFileSync from './writeFileSync-CJp1kXQR.js';
|
|
3
|
-
|
|
4
|
-
function writeYamlSync(path, data, replacer, options) {
|
|
5
|
-
let stringifyOptions;
|
|
6
|
-
let effectiveReplacer;
|
|
7
|
-
let space;
|
|
8
|
-
if (typeof replacer === "object" && replacer !== null && !Array.isArray(replacer) && typeof replacer !== "function") {
|
|
9
|
-
stringifyOptions = replacer;
|
|
10
|
-
effectiveReplacer = stringifyOptions.replacer;
|
|
11
|
-
space = stringifyOptions.space;
|
|
12
|
-
} else if (typeof options === "object" && options !== null) {
|
|
13
|
-
stringifyOptions = options;
|
|
14
|
-
effectiveReplacer = replacer;
|
|
15
|
-
space = stringifyOptions.space ?? (typeof options === "number" || typeof options === "string" ? options : void 0);
|
|
16
|
-
} else {
|
|
17
|
-
effectiveReplacer = replacer;
|
|
18
|
-
space = options;
|
|
19
|
-
}
|
|
20
|
-
const content = stringify(data, effectiveReplacer, space ?? stringifyOptions);
|
|
21
|
-
writeFileSync(path, content, stringifyOptions);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { writeYamlSync as default };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { ContentType, ReadFileOptions } from "../types.d.ts";
|
|
2
|
-
type DecompressionMethod = (buffer: Buffer, callback: (error: Error | null, result: Buffer) => void) => void;
|
|
3
|
-
declare const decompressionMethods: Record<string, DecompressionMethod>;
|
|
4
|
-
/**
|
|
5
|
-
* Synchronously reads the entire contents of a file.
|
|
6
|
-
* It can also decompress the file content if a `compression` option is provided.
|
|
7
|
-
* @template O - The type of the options object, extending {@link ReadFileOptions}.
|
|
8
|
-
* @param path The path to the file to read. Can be a file URL or a string path.
|
|
9
|
-
* @param options Optional configuration for reading the file. See {@link ReadFileOptions}.
|
|
10
|
-
* Available `compression` methods: "brotli", "gzip", "none" (default).
|
|
11
|
-
* @returns The file content. The type of the content (string or Buffer)
|
|
12
|
-
* depends on the `buffer` option (defaults to string if `buffer` is false or not set).
|
|
13
|
-
* @example
|
|
14
|
-
* ```javascript
|
|
15
|
-
* import { readFileSync } from "@visulima/fs";
|
|
16
|
-
* import { join } from "node:path";
|
|
17
|
-
*
|
|
18
|
-
* try {
|
|
19
|
-
* // Read a regular text file
|
|
20
|
-
* const content = readFileSync(join("path", "to", "my-file.txt"));
|
|
21
|
-
* console.log("File content:", content);
|
|
22
|
-
*
|
|
23
|
-
* // Read a file as a Buffer
|
|
24
|
-
* const bufferContent = readFileSync(join("path", "to", "another-file.bin"), { buffer: true });
|
|
25
|
-
* console.log("Buffer length:", bufferContent.length);
|
|
26
|
-
*
|
|
27
|
-
* // Read and decompress a gzipped file
|
|
28
|
-
* // Assume my-archive.txt.gz exists
|
|
29
|
-
* // const decompressedContent = readFileSync(join("path", "to", "my-archive.txt.gz"), { compression: "gzip", encoding: "utf8" });
|
|
30
|
-
* // console.log("Decompressed content:", decompressedContent);
|
|
31
|
-
* } catch (error) {
|
|
32
|
-
* console.error("Failed to read file:", error);
|
|
33
|
-
* }
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
declare const readFileSync: <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(path: URL | string, options?: O) => ContentType<O>;
|
|
37
|
-
export default readFileSync;
|
package/dist/read/read-file.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { ContentType, ReadFileOptions } from "../types.d.ts";
|
|
2
|
-
type DecompressionMethod = (buffer: Buffer, callback: (error: Error | null, result: Buffer) => void) => void;
|
|
3
|
-
declare const decompressionMethods: Record<string, DecompressionMethod>;
|
|
4
|
-
/**
|
|
5
|
-
* Asynchronously reads the entire contents of a file.
|
|
6
|
-
* It can also decompress the file content if a `compression` option is provided.
|
|
7
|
-
* @template O - The type of the options object, extending {@link ReadFileOptions}.
|
|
8
|
-
* @param path The path to the file to read. Can be a file URL or a string path.
|
|
9
|
-
* @param options Optional configuration for reading the file. See {@link ReadFileOptions}.
|
|
10
|
-
* Available `compression` methods: "brotli", "gzip", "none" (default).
|
|
11
|
-
* @returns A promise that resolves with the file content. The type of the content (string or Buffer)
|
|
12
|
-
* depends on the `buffer` option (defaults to string if `buffer` is false or not set).
|
|
13
|
-
* @example
|
|
14
|
-
* ```javascript
|
|
15
|
-
* import { readFile } from "@visulima/fs";
|
|
16
|
-
* import { join } from "node:path";
|
|
17
|
-
*
|
|
18
|
-
* const readMyFile = async () => {
|
|
19
|
-
* try {
|
|
20
|
-
* // Read a regular text file
|
|
21
|
-
* const content = await readFile(join("path", "to", "my-file.txt"));
|
|
22
|
-
* console.log("File content:", content);
|
|
23
|
-
*
|
|
24
|
-
* // Read a file as a Buffer
|
|
25
|
-
* const bufferContent = await readFile(join("path", "to", "another-file.bin"), { buffer: true });
|
|
26
|
-
* console.log("Buffer length:", bufferContent.length);
|
|
27
|
-
*
|
|
28
|
-
* // Read and decompress a gzipped file
|
|
29
|
-
* // Assume my-archive.txt.gz exists
|
|
30
|
-
* // const decompressedContent = await readFile(join("path", "to", "my-archive.txt.gz"), { compression: "gzip", encoding: "utf8" });
|
|
31
|
-
* // console.log("Decompressed content:", decompressedContent);
|
|
32
|
-
* } catch (error) {
|
|
33
|
-
* console.error("Failed to read file:", error);
|
|
34
|
-
* }
|
|
35
|
-
* };
|
|
36
|
-
*
|
|
37
|
-
* readMyFile();
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
declare const readFile: <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(path: URL | string, options?: O) => Promise<ContentType<O>>;
|
|
41
|
-
export default readFile;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { JsonValue } from "type-fest";
|
|
2
|
-
import type { JsonReviver, ReadJsonOptions } from "../types.d.ts";
|
|
3
|
-
declare function readJsonSync<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): T;
|
|
4
|
-
declare function readJsonSync<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): T;
|
|
5
|
-
export default readJsonSync;
|
package/dist/read/read-json.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { JsonValue } from "type-fest";
|
|
2
|
-
import type { JsonReviver, ReadJsonOptions } from "../types.d.ts";
|
|
3
|
-
declare function readJson<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): Promise<T>;
|
|
4
|
-
declare function readJson<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): Promise<T>;
|
|
5
|
-
export default readJson;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { CompressionType, ReadYamlOptions, YamlReviver } from "../types.d.ts";
|
|
2
|
-
declare function readYamlSync<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<CompressionType>): R;
|
|
3
|
-
declare function readYamlSync<R = Record<string, unknown>>(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<CompressionType>): R;
|
|
4
|
-
export default readYamlSync;
|
package/dist/read/read-yaml.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { CompressionType, ReadYamlOptions, YamlReviver } from "../types.d.ts";
|
|
2
|
-
declare function readYaml<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<CompressionType>): Promise<R>;
|
|
3
|
-
declare function readYaml<R = Record<string, unknown>>(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<CompressionType>): Promise<R>;
|
|
4
|
-
export default readYaml;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { RetryOptions } from "../types.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Ensures that a directory is empty.
|
|
4
|
-
* Deletes directory contents if the directory is not empty.
|
|
5
|
-
* If the directory does not exist, it is created.
|
|
6
|
-
* The directory itself is not deleted.
|
|
7
|
-
* @param dir The path to the directory to empty.
|
|
8
|
-
* @param options Optional configuration for the operation. See {@link RetryOptions}.
|
|
9
|
-
* @example
|
|
10
|
-
* ```javascript
|
|
11
|
-
* import { emptyDirSync } from "@visulima/fs";
|
|
12
|
-
* import { join } from "node:path";
|
|
13
|
-
*
|
|
14
|
-
* try {
|
|
15
|
-
* emptyDirSync(join("/tmp", "my-app-temp"));
|
|
16
|
-
* console.log("Temporary directory emptied or created.");
|
|
17
|
-
* } catch (error) {
|
|
18
|
-
* console.error("Failed to empty directory:", error);
|
|
19
|
-
* }
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
declare const emptyDirSync: (dir: URL | string, options?: RetryOptions) => void;
|
|
23
|
-
export default emptyDirSync;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { RetryOptions } from "../types.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Ensures that a directory is empty.
|
|
4
|
-
* Deletes directory contents if the directory is not empty.
|
|
5
|
-
* If the directory does not exist, it is created.
|
|
6
|
-
* The directory itself is not deleted.
|
|
7
|
-
* @param dir The path to the directory to empty.
|
|
8
|
-
* @param options Optional configuration for the operation. See {@link RetryOptions}.
|
|
9
|
-
* @returns A promise that resolves when the directory is empty.
|
|
10
|
-
* @example
|
|
11
|
-
* ```javascript
|
|
12
|
-
* import { emptyDir } from "@visulima/fs";
|
|
13
|
-
* import { join } from "node:path";
|
|
14
|
-
*
|
|
15
|
-
* const clearTempDir = async () => {
|
|
16
|
-
* try {
|
|
17
|
-
* await emptyDir(join("/tmp", "my-app-temp"));
|
|
18
|
-
* console.log("Temporary directory emptied or created.");
|
|
19
|
-
* } catch (error) {
|
|
20
|
-
* console.error("Failed to empty directory:", error);
|
|
21
|
-
* }
|
|
22
|
-
* };
|
|
23
|
-
*
|
|
24
|
-
* clearTempDir();
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
declare const emptyDir: (dir: URL | string, options?: RetryOptions) => Promise<void>;
|
|
28
|
-
export default emptyDir;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { RetryOptions } from "../types.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Synchronously removes a file or directory (recursively).
|
|
4
|
-
* If the path does not exist, it does nothing.
|
|
5
|
-
* @param path The path to the file or directory to remove.
|
|
6
|
-
* @param options Optional configuration for the operation. See {@link RetryOptions}.
|
|
7
|
-
* @example
|
|
8
|
-
* ```javascript
|
|
9
|
-
* import { removeSync } from "@visulima/fs";
|
|
10
|
-
* import { join } from "node:path";
|
|
11
|
-
*
|
|
12
|
-
* try {
|
|
13
|
-
* removeSync(join("/tmp", "my-file.txt"));
|
|
14
|
-
* console.log("File /tmp/my-file.txt removed.");
|
|
15
|
-
*
|
|
16
|
-
* removeSync(join("/tmp", "my-empty-dir"));
|
|
17
|
-
* console.log("Directory /tmp/my-empty-dir removed.");
|
|
18
|
-
*
|
|
19
|
-
* removeSync(join("/tmp", "my-dir-with-contents"));
|
|
20
|
-
* console.log("Directory /tmp/my-dir-with-contents and its contents removed.");
|
|
21
|
-
* } catch (error) {
|
|
22
|
-
* console.error("Failed to remove path:", error);
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
declare const removeSync: (path: URL | string, options?: RetryOptions) => void;
|
|
27
|
-
export default removeSync;
|
package/dist/remove/remove.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { RetryOptions } from "../types.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Asynchronously removes a file or directory (recursively).
|
|
4
|
-
* If the path does not exist, it does nothing.
|
|
5
|
-
* @param path The path to the file or directory to remove.
|
|
6
|
-
* @param options Optional configuration for the operation. See {@link RetryOptions}.
|
|
7
|
-
* @returns A promise that resolves when the path has been removed.
|
|
8
|
-
* @example
|
|
9
|
-
* ```javascript
|
|
10
|
-
* import { remove } from "@visulima/fs";
|
|
11
|
-
* import { join } from "node:path";
|
|
12
|
-
*
|
|
13
|
-
* const deleteFileOrDir = async () => {
|
|
14
|
-
* try {
|
|
15
|
-
* await remove(join("/tmp", "my-file.txt"));
|
|
16
|
-
* console.log("File /tmp/my-file.txt removed.");
|
|
17
|
-
*
|
|
18
|
-
* await remove(join("/tmp", "my-empty-dir"));
|
|
19
|
-
* console.log("Directory /tmp/my-empty-dir removed.");
|
|
20
|
-
*
|
|
21
|
-
* await remove(join("/tmp", "my-dir-with-contents"));
|
|
22
|
-
* console.log("Directory /tmp/my-dir-with-contents and its contents removed.");
|
|
23
|
-
* } catch (error) {
|
|
24
|
-
* console.error("Failed to remove path:", error);
|
|
25
|
-
* }
|
|
26
|
-
* };
|
|
27
|
-
*
|
|
28
|
-
* deleteFileOrDir();
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
declare const remove: (path: URL | string, options?: RetryOptions) => Promise<void>;
|
|
32
|
-
export default remove;
|