@visulima/fs 5.0.0-alpha.12 → 5.0.0-alpha.14

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.
Files changed (195) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE.md +52 -4
  3. package/dist/eol.d.ts +30 -0
  4. package/dist/eol.js +3 -26
  5. package/dist/error.d.ts +243 -13
  6. package/dist/error.js +1 -7
  7. package/dist/glob-parent.d.ts +30 -0
  8. package/dist/glob-parent.js +1 -90
  9. package/dist/glob.d.ts +2 -3
  10. package/dist/glob.js +1 -2
  11. package/dist/index.d.ts +784 -7
  12. package/dist/index.js +1 -38
  13. package/dist/ini.d.ts +63 -3
  14. package/dist/ini.js +1 -4
  15. package/dist/is-glob.d.ts +29 -0
  16. package/dist/is-glob.js +1 -9
  17. package/dist/json5.d.ts +27 -3
  18. package/dist/json5.js +1 -4
  19. package/dist/jsonc.d.ts +58 -3
  20. package/dist/jsonc.js +1 -4
  21. package/dist/match.d.ts +44 -3
  22. package/dist/match.js +1 -15
  23. package/dist/packem_shared/AlreadyExistsError-CEu6_Tjb.js +1 -0
  24. package/dist/packem_shared/DirectoryError-ddlbUV8C.js +1 -0
  25. package/dist/packem_shared/F_OK-CAwY1qU7.js +1 -0
  26. package/dist/packem_shared/JSONError-D7h6PNWc.js +4 -0
  27. package/dist/packem_shared/NotEmptyError-DMh1o7UL.js +1 -0
  28. package/dist/packem_shared/NotFoundError-BPiW0icm.js +1 -0
  29. package/dist/packem_shared/PermissionError-B1Emi5a9.js +1 -0
  30. package/dist/packem_shared/WalkError-Olmh4908.js +1 -0
  31. package/dist/packem_shared/_commonjsHelpers-D6W6KoPK.js +1 -0
  32. package/dist/packem_shared/assertValidFileContents-BZFnXa7K.js +1 -0
  33. package/dist/packem_shared/assertValidFileOrDirectoryPath-DgPIPmZT.js +1 -0
  34. package/dist/packem_shared/build-rm-options-C1R4reBu.js +1 -0
  35. package/dist/packem_shared/collect-2KPTpCdX.js +1 -0
  36. package/dist/packem_shared/collectSync-BX55r_BH.js +1 -0
  37. package/dist/packem_shared/emptyDir-8utO028L.js +1 -0
  38. package/dist/packem_shared/emptyDirSync-Bk5fUX73.js +1 -0
  39. package/dist/packem_shared/ensureDir-CZ4oUFuo.js +1 -0
  40. package/dist/packem_shared/ensureDirSync-CoPWhbjM.js +1 -0
  41. package/dist/packem_shared/ensureFile-CF1cAAyh.js +1 -0
  42. package/dist/packem_shared/ensureFileSync-C3qR6naU.js +1 -0
  43. package/dist/packem_shared/ensureLink-LLLxlGHn.js +1 -0
  44. package/dist/packem_shared/ensureLinkSync-Dh_GtT8F.js +1 -0
  45. package/dist/packem_shared/ensureSymlink-D50kj2zl.js +1 -0
  46. package/dist/packem_shared/ensureSymlinkSync-BbVDPvI4.js +1 -0
  47. package/dist/packem_shared/findUp-BT07y_Me.js +1 -0
  48. package/dist/packem_shared/findUpSync-BvZiYsKJ.js +1 -0
  49. package/dist/packem_shared/get-file-info-type-CaWGXRjY.js +1 -0
  50. package/dist/packem_shared/glob-MHJQjR39.js +1 -0
  51. package/dist/packem_shared/glob-sync.d-p6lOZXnE.d.ts +54 -0
  52. package/dist/packem_shared/globSync-CwzlELgS.js +1 -0
  53. package/dist/packem_shared/index-CYIVJA0W.js +1 -0
  54. package/dist/packem_shared/index-DrapuBsB.js +1 -0
  55. package/dist/packem_shared/index-K-NNTkpb.js +11 -0
  56. package/dist/packem_shared/index-yGx8uzZs.js +1 -0
  57. package/dist/packem_shared/indexToLineColumn-BRSZFC6I-BKj3uzZt.js +6 -0
  58. package/dist/packem_shared/ini-preserve-CXc_xkpG.js +4 -0
  59. package/dist/packem_shared/is-stats-identical-CohsLtWy.js +1 -0
  60. package/dist/packem_shared/isAccessible-CDFxsAAo.js +1 -0
  61. package/dist/packem_shared/isAccessibleSync-5nzZWgin.js +1 -0
  62. package/dist/packem_shared/isFsCaseSensitive-CMZVY1A2.js +1 -0
  63. package/dist/packem_shared/json-error.d-DVILOyHc.d.ts +52 -0
  64. package/dist/packem_shared/jsonc-merge-CQMjx3Vw.js +2 -0
  65. package/dist/packem_shared/move-LmP6P9sn.js +1 -0
  66. package/dist/packem_shared/parseJson-Xx6vHYbv.js +1 -0
  67. package/dist/packem_shared/readFile-BAVMZg5e.js +1 -0
  68. package/dist/packem_shared/readFileSync-CGmzMUF2.js +1 -0
  69. package/dist/packem_shared/readIni-Cfl6HmTS.js +1 -0
  70. package/dist/packem_shared/readIniSync-DPg4UD0P.js +1 -0
  71. package/dist/packem_shared/readJson-kPx68Wv1.js +1 -0
  72. package/dist/packem_shared/readJson5-pXTL9nUE.js +1 -0
  73. package/dist/packem_shared/readJson5Sync-BedQc292.js +1 -0
  74. package/dist/packem_shared/readJsonSync-_HXNI3Se.js +1 -0
  75. package/dist/packem_shared/readJsonc-BzvuAXbT.js +1 -0
  76. package/dist/packem_shared/readJsoncSync-CVG1_QnX.js +1 -0
  77. package/dist/packem_shared/readToml-BO5CZK2P.js +1 -0
  78. package/dist/packem_shared/readTomlSync-1fKo0R52.js +1 -0
  79. package/dist/packem_shared/readYaml-DjK_Vqj1.js +1 -0
  80. package/dist/packem_shared/readYamlSync-C3h6KA2c.js +1 -0
  81. package/dist/packem_shared/remove-DH41Ov_c.js +1 -0
  82. package/dist/packem_shared/removeSync-50OEdnHd.js +1 -0
  83. package/dist/packem_shared/resolve-symlink-target-BofZSDIc.js +1 -0
  84. package/dist/packem_shared/sanitize-CU1xmyrg.js +1 -0
  85. package/dist/packem_shared/stripJsonComments-CzNR77MF.js +1 -0
  86. package/dist/packem_shared/to-uint-8-array-DwgaTasY.js +1 -0
  87. package/dist/packem_shared/types.d-BsmmADqx.d.ts +1660 -0
  88. package/dist/packem_shared/walk-D01Qmmvz.js +1 -0
  89. package/dist/packem_shared/walk-include-DCiVAwMP.js +1 -0
  90. package/dist/packem_shared/walkSync-BknSdmKD.js +1 -0
  91. package/dist/packem_shared/writeFile-DNGaDOMX.js +1 -0
  92. package/dist/packem_shared/writeFileSync-CE1i-eMA.js +1 -0
  93. package/dist/packem_shared/writeIni-DG7U4ji0.js +4 -0
  94. package/dist/packem_shared/writeIniSync-Ldt6HFLb.js +4 -0
  95. package/dist/packem_shared/writeJson-BkGlq1Kv.js +4 -0
  96. package/dist/packem_shared/writeJson5-Btud4sQh.js +4 -0
  97. package/dist/packem_shared/writeJson5Sync-Iln3i1IV.js +4 -0
  98. package/dist/packem_shared/writeJsonSync-HndmyvEK.js +4 -0
  99. package/dist/packem_shared/writeJsonc-9oiamG16.js +4 -0
  100. package/dist/packem_shared/writeJsoncSync-BHBziPiK.js +4 -0
  101. package/dist/packem_shared/writeToml-Cj57wZ8B.js +1 -0
  102. package/dist/packem_shared/writeTomlSync-B34ZZp0e.js +1 -0
  103. package/dist/packem_shared/writeYaml-BhQX2yN9.js +1 -0
  104. package/dist/packem_shared/writeYamlSync-DG01FBeC.js +1 -0
  105. package/dist/size.d.ts +244 -0
  106. package/dist/size.js +1 -146
  107. package/dist/toml.d.ts +56 -2
  108. package/dist/toml.js +1 -4
  109. package/dist/utils.d.ts +91 -3
  110. package/dist/utils.js +1 -6
  111. package/dist/yaml.d.ts +2 -3
  112. package/dist/yaml.js +1 -4
  113. package/package.json +39 -40
  114. package/dist/packem_shared/AlreadyExistsError-6Y9hjgMn.js +0 -27
  115. package/dist/packem_shared/DirectoryError-BfYPkIYP.js +0 -27
  116. package/dist/packem_shared/F_OK-MldBaGxb.js +0 -8
  117. package/dist/packem_shared/JSONError-BkHRnInH.js +0 -26
  118. package/dist/packem_shared/NotEmptyError-B21RUlVr.js +0 -27
  119. package/dist/packem_shared/NotFoundError-BIp61X6k.js +0 -27
  120. package/dist/packem_shared/PermissionError-CjoiJgip.js +0 -27
  121. package/dist/packem_shared/WalkError-DER5A43G.js +0 -24
  122. package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +0 -5
  123. package/dist/packem_shared/assertValidFileContents-BmcLtsGd.js +0 -7
  124. package/dist/packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js +0 -7
  125. package/dist/packem_shared/build-rm-options-Cl3VDY4O.js +0 -12
  126. package/dist/packem_shared/collect-CqQ3eVab.js +0 -14
  127. package/dist/packem_shared/collectSync-noE08NNv.js +0 -14
  128. package/dist/packem_shared/emptyDir-DnwENOaV.js +0 -46
  129. package/dist/packem_shared/emptyDirSync-6WiHBo8a.js +0 -43
  130. package/dist/packem_shared/ensureDir-DNlPftys.js +0 -53
  131. package/dist/packem_shared/ensureDirSync-DcPZFMy5.js +0 -53
  132. package/dist/packem_shared/ensureFile-BRQpUOUM.js +0 -47
  133. package/dist/packem_shared/ensureFileSync-SBY7A9-C.js +0 -47
  134. package/dist/packem_shared/ensureLink-DJQeauEn.js +0 -55
  135. package/dist/packem_shared/ensureLinkSync-D9RVAglV.js +0 -55
  136. package/dist/packem_shared/ensureSymlink-CoRYDRwr.js +0 -80
  137. package/dist/packem_shared/ensureSymlinkSync-CFimFlgh.js +0 -81
  138. package/dist/packem_shared/findUp-YcNLKdfV.js +0 -84
  139. package/dist/packem_shared/findUpSync-BfA5fheN.js +0 -83
  140. package/dist/packem_shared/get-file-info-type-FD4-jsyg.js +0 -14
  141. package/dist/packem_shared/glob-DY8l7izD.js +0 -5
  142. package/dist/packem_shared/glob-sync.d-BlGjS68e.d.ts +0 -4
  143. package/dist/packem_shared/globSync-5P2KJf_g.js +0 -5
  144. package/dist/packem_shared/index-C8W8sfzP.js +0 -830
  145. package/dist/packem_shared/index-CHM-in-V.js +0 -100
  146. package/dist/packem_shared/index-bhgnhm4u.js +0 -167
  147. package/dist/packem_shared/index-xe4o3cYi.js +0 -1784
  148. package/dist/packem_shared/indexToLineColumn-BUb0GPKl-BF770uX7.js +0 -171
  149. package/dist/packem_shared/ini-preserve-Dq_Q_Jgb.js +0 -251
  150. package/dist/packem_shared/is-stats-identical-D8FxpvQU.js +0 -3
  151. package/dist/packem_shared/isAccessible-DuVrTNFV.js +0 -38
  152. package/dist/packem_shared/isAccessibleSync-DI8mM0fA.js +0 -38
  153. package/dist/packem_shared/isFsCaseSensitive-DunL7Iry.js +0 -62
  154. package/dist/packem_shared/json-error.d-DgKaeuIf.d.ts +0 -10
  155. package/dist/packem_shared/jsonc-merge-C6jWcfWh.js +0 -72
  156. package/dist/packem_shared/move-DbpW5_vA.js +0 -134
  157. package/dist/packem_shared/parseJson-BIp89Xjo.js +0 -63
  158. package/dist/packem_shared/readFile-Iz7kvCCk.js +0 -65
  159. package/dist/packem_shared/readFileSync-gm9yfIhh.js +0 -54
  160. package/dist/packem_shared/readIni-CJ2xfpjB.js +0 -10
  161. package/dist/packem_shared/readIniSync-9LUjaSSp.js +0 -10
  162. package/dist/packem_shared/readJson-C_rwm-wq.js +0 -22
  163. package/dist/packem_shared/readJson5-mBoTZppy.js +0 -15
  164. package/dist/packem_shared/readJson5Sync-8WS2yUok.js +0 -15
  165. package/dist/packem_shared/readJsonSync-BMEmCcJ6.js +0 -22
  166. package/dist/packem_shared/readJsonc-j-OS-APg.js +0 -28
  167. package/dist/packem_shared/readJsoncSync-Aw6EMlWO.js +0 -16
  168. package/dist/packem_shared/readToml-B2MHaSes.js +0 -9
  169. package/dist/packem_shared/readTomlSync-DNbK8NEb.js +0 -9
  170. package/dist/packem_shared/readYaml-D5q2a0e1.js +0 -10
  171. package/dist/packem_shared/readYamlSync-BKX-PAfq.js +0 -10
  172. package/dist/packem_shared/remove-C8_gl3jF.js +0 -39
  173. package/dist/packem_shared/removeSync-BJR_wTwN.js +0 -39
  174. package/dist/packem_shared/resolve-symlink-target-Kh4GovFf.js +0 -16
  175. package/dist/packem_shared/sanitize-BZoLN9Fg.js +0 -205
  176. package/dist/packem_shared/stripJsonComments-vo4k0mpF.js +0 -19
  177. package/dist/packem_shared/to-uint-8-array-Dz2nF1y1.js +0 -19
  178. package/dist/packem_shared/types.d-CYpAhWov.d.ts +0 -145
  179. package/dist/packem_shared/walk-CSZgCuDx.js +0 -124
  180. package/dist/packem_shared/walk-include-CZco7BvN.js +0 -16
  181. package/dist/packem_shared/walkSync-C4Cy28xb.js +0 -123
  182. package/dist/packem_shared/writeFile-B8HX0JIQ.js +0 -81
  183. package/dist/packem_shared/writeFileSync-DB8vv8xR.js +0 -81
  184. package/dist/packem_shared/writeIni-i55QrL8y.js +0 -65
  185. package/dist/packem_shared/writeIniSync-CLqJE5t3.js +0 -64
  186. package/dist/packem_shared/writeJson-Bo7C2UHw.js +0 -50
  187. package/dist/packem_shared/writeJson5-vVmHUQOd.js +0 -53
  188. package/dist/packem_shared/writeJson5Sync-oJ546h5k.js +0 -53
  189. package/dist/packem_shared/writeJsonSync-BKZ_9Acr.js +0 -50
  190. package/dist/packem_shared/writeJsonc-BufH_oC5.js +0 -60
  191. package/dist/packem_shared/writeJsoncSync-DB9be1YL.js +0 -59
  192. package/dist/packem_shared/writeToml-DgTW_-7F.js +0 -8
  193. package/dist/packem_shared/writeTomlSync-DiBiE9ja.js +0 -8
  194. package/dist/packem_shared/writeYaml-BWCOome-.js +0 -24
  195. package/dist/packem_shared/writeYamlSync-DBVnXmuY.js +0 -24
@@ -1,81 +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
- options.chown ??= { gid: stat$1.gid, uid: stat$1.uid };
62
- await rename(path, `${path}.bak`);
63
- }
64
- if (options.chown) {
65
- try {
66
- await chown(temporaryPath, options.chown.uid, options.chown.gid);
67
- } catch {
68
- }
69
- }
70
- await chmod(temporaryPath, stat$1 && !options.mode ? stat$1.mode : options.mode ?? 438);
71
- await rename(temporaryPath, path);
72
- } catch (error) {
73
- throw new Error(`Failed to write file at: ${path} - ${error.message}`, { cause: error });
74
- } finally {
75
- if (await isAccessible(temporaryPath)) {
76
- await unlink(`${path}.tmp`);
77
- }
78
- }
79
- };
80
-
81
- export { writeFile as default };
@@ -1,81 +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
- options.chown ??= { gid: stat.gid, uid: stat.uid };
62
- renameSync(path, `${path}.bak`);
63
- }
64
- if (options.chown) {
65
- try {
66
- chownSync(temporaryPath, options.chown.uid, options.chown.gid);
67
- } catch {
68
- }
69
- }
70
- chmodSync(temporaryPath, stat && !options.mode ? stat.mode : options.mode ?? 438);
71
- renameSync(temporaryPath, path);
72
- } catch (error) {
73
- throw new Error(`Failed to write file at: ${path} - ${error.message}`, { cause: error });
74
- } finally {
75
- if (isAccessibleSync(temporaryPath)) {
76
- unlinkSync(`${path}.tmp`);
77
- }
78
- }
79
- };
80
-
81
- export { writeFileSync as default };
@@ -1,65 +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 { parse, stringify } from 'ini';
24
- import { R_OK } from './F_OK-MldBaGxb.js';
25
- import isAccessible from './isAccessible-DuVrTNFV.js';
26
- import { d as detectIniStyle, m as mergeIniPreservingLines } from './ini-preserve-Dq_Q_Jgb.js';
27
- import writeFile from './writeFile-B8HX0JIQ.js';
28
-
29
- const writeIni = async (path, data, options = {}) => {
30
- const { eol, preserveStyle = true, whitespace, ...rest } = options;
31
- const { align, bracketedArray, newline, platform, section, sort, ...writeOptions } = rest;
32
- let resolvedEol = eol;
33
- let resolvedWhitespace = whitespace;
34
- let existingText;
35
- let oldData;
36
- const accessible = preserveStyle ? await isAccessible(path, R_OK) : false;
37
- if (accessible) {
38
- try {
39
- existingText = await readFile(path, "utf8");
40
- oldData = parse(existingText, { bracketedArray: bracketedArray ?? true });
41
- const detected = detectIniStyle(existingText);
42
- resolvedEol ??= detected.eol;
43
- resolvedWhitespace ??= detected.whitespace;
44
- } catch (error) {
45
- if (error.code !== "ENOENT") {
46
- throw error;
47
- }
48
- }
49
- }
50
- const encodeOptions = { align, bracketedArray, newline, platform, section, sort, whitespace: resolvedWhitespace };
51
- const freshStringify = (value, sectionName) => stringify(value, sectionName === void 0 ? encodeOptions : { ...encodeOptions, section: sectionName });
52
- let output;
53
- if (existingText !== void 0 && oldData) {
54
- output = mergeIniPreservingLines(existingText, oldData, data, freshStringify, {
55
- eol: resolvedEol ?? "\n"});
56
- } else {
57
- output = freshStringify(data, section);
58
- if (resolvedEol === "\r\n") {
59
- output = output.replaceAll(/\r?\n/g, "\r\n");
60
- }
61
- }
62
- await writeFile(path, output, writeOptions);
63
- };
64
-
65
- export { writeIni as default };
@@ -1,64 +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 { parse, stringify } from 'ini';
24
- import { R_OK } from './F_OK-MldBaGxb.js';
25
- import isAccessibleSync from './isAccessibleSync-DI8mM0fA.js';
26
- import { d as detectIniStyle, m as mergeIniPreservingLines } from './ini-preserve-Dq_Q_Jgb.js';
27
- import writeFileSync from './writeFileSync-DB8vv8xR.js';
28
-
29
- const writeIniSync = (path, data, options = {}) => {
30
- const { eol, preserveStyle = true, whitespace, ...rest } = options;
31
- const { align, bracketedArray, newline, platform, section, sort, ...writeOptions } = rest;
32
- let resolvedEol = eol;
33
- let resolvedWhitespace = whitespace;
34
- let existingText;
35
- let oldData;
36
- if (preserveStyle && isAccessibleSync(path, R_OK)) {
37
- try {
38
- existingText = readFileSync(path, "utf8");
39
- oldData = parse(existingText, { bracketedArray: bracketedArray ?? true });
40
- const detected = detectIniStyle(existingText);
41
- resolvedEol ??= detected.eol;
42
- resolvedWhitespace ??= detected.whitespace;
43
- } catch (error) {
44
- if (error.code !== "ENOENT") {
45
- throw error;
46
- }
47
- }
48
- }
49
- const encodeOptions = { align, bracketedArray, newline, platform, section, sort, whitespace: resolvedWhitespace };
50
- const freshStringify = (value, sectionName) => stringify(value, sectionName === void 0 ? encodeOptions : { ...encodeOptions, section: sectionName });
51
- let output;
52
- if (existingText !== void 0 && oldData) {
53
- output = mergeIniPreservingLines(existingText, oldData, data, freshStringify, {
54
- eol: resolvedEol ?? "\n"});
55
- } else {
56
- output = freshStringify(data, section);
57
- if (resolvedEol === "\r\n") {
58
- output = output.replaceAll(/\r?\n/g, "\r\n");
59
- }
60
- }
61
- writeFileSync(path, output, writeOptions);
62
- };
63
-
64
- export { writeIniSync 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-B8HX0JIQ.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,53 +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 JSON5 from 'json5';
25
- import { R_OK } from './F_OK-MldBaGxb.js';
26
- import isAccessible from './isAccessible-DuVrTNFV.js';
27
- import writeFile from './writeFile-B8HX0JIQ.js';
28
-
29
- const writeJson5 = async (path, data, options = {}) => {
30
- const { detectIndent: detectIndent$1, indent: indentOption, quote, replacer, ...writeOptions } = { indent: " ", ...options };
31
- let indent = indentOption;
32
- let trailingNewline = "\n";
33
- if (await isAccessible(path, R_OK)) {
34
- try {
35
- const file = await readFile(path, "utf8");
36
- if (detectIndent$1) {
37
- const { indent: detectedIndent } = detectIndent(file);
38
- if (detectedIndent) {
39
- indent = detectedIndent;
40
- }
41
- }
42
- trailingNewline = file.endsWith("\n") ? "\n" : "";
43
- } catch (error) {
44
- if (error.code !== "ENOENT") {
45
- throw error;
46
- }
47
- }
48
- }
49
- const output = JSON5.stringify(data, { quote, replacer, space: indent });
50
- await writeFile(path, `${output}${trailingNewline}`, writeOptions);
51
- };
52
-
53
- export { writeJson5 as default };
@@ -1,53 +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 JSON5 from 'json5';
25
- import { R_OK } from './F_OK-MldBaGxb.js';
26
- import isAccessibleSync from './isAccessibleSync-DI8mM0fA.js';
27
- import writeFileSync from './writeFileSync-DB8vv8xR.js';
28
-
29
- const writeJson5Sync = (path, data, options = {}) => {
30
- const { detectIndent: detectIndent$1, indent: indentOption, quote, replacer, ...writeOptions } = { indent: " ", ...options };
31
- let indent = indentOption;
32
- let trailingNewline = "\n";
33
- if (isAccessibleSync(path, R_OK)) {
34
- try {
35
- const file = readFileSync(path, "utf8");
36
- if (detectIndent$1) {
37
- const { indent: detectedIndent } = detectIndent(file);
38
- if (detectedIndent) {
39
- indent = detectedIndent;
40
- }
41
- }
42
- trailingNewline = file.endsWith("\n") ? "\n" : "";
43
- } catch (error) {
44
- if (error.code !== "ENOENT") {
45
- throw error;
46
- }
47
- }
48
- }
49
- const output = JSON5.stringify(data, { quote, replacer, space: indent });
50
- writeFileSync(path, `${output}${trailingNewline}`, writeOptions);
51
- };
52
-
53
- export { writeJson5Sync 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-DB8vv8xR.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,60 +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 { b as buildJsoncOutput } from './jsonc-merge-C6jWcfWh.js';
27
- import writeFile from './writeFile-B8HX0JIQ.js';
28
-
29
- const readExisting = async (path, detectIndent$1, fallbackIndent) => {
30
- let existingText;
31
- let indent = fallbackIndent;
32
- let trailingNewline = "\n";
33
- const accessible = await isAccessible(path, R_OK);
34
- if (!accessible) {
35
- return { indent, trailingNewline };
36
- }
37
- try {
38
- existingText = await readFile(path, "utf8");
39
- if (detectIndent$1) {
40
- const { indent: detectedIndent } = detectIndent(existingText);
41
- if (detectedIndent) {
42
- indent = detectedIndent;
43
- }
44
- }
45
- trailingNewline = existingText.endsWith("\n") ? "\n" : "";
46
- } catch (error) {
47
- if (error.code !== "ENOENT") {
48
- throw error;
49
- }
50
- }
51
- return { existingText, indent, trailingNewline };
52
- };
53
- const writeJsonc = async (path, data, options = {}) => {
54
- const { detectIndent, formattingOptions, indent: indentOption, preserveComments = true, replacer, ...writeOptions } = { indent: " ", ...options };
55
- const { existingText, indent, trailingNewline } = await readExisting(path, detectIndent, indentOption);
56
- const output = buildJsoncOutput(existingText, data, preserveComments, indent, trailingNewline, formattingOptions, replacer);
57
- await writeFile(path, output, writeOptions);
58
- };
59
-
60
- export { writeJsonc as default };
@@ -1,59 +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 { b as buildJsoncOutput } from './jsonc-merge-C6jWcfWh.js';
27
- import writeFileSync from './writeFileSync-DB8vv8xR.js';
28
-
29
- const readExistingSync = (path, detectIndent$1, fallbackIndent) => {
30
- let existingText;
31
- let indent = fallbackIndent;
32
- let trailingNewline = "\n";
33
- if (!isAccessibleSync(path, R_OK)) {
34
- return { indent, trailingNewline };
35
- }
36
- try {
37
- existingText = readFileSync(path, "utf8");
38
- if (detectIndent$1) {
39
- const { indent: detectedIndent } = detectIndent(existingText);
40
- if (detectedIndent) {
41
- indent = detectedIndent;
42
- }
43
- }
44
- trailingNewline = existingText.endsWith("\n") ? "\n" : "";
45
- } catch (error) {
46
- if (error.code !== "ENOENT") {
47
- throw error;
48
- }
49
- }
50
- return { existingText, indent, trailingNewline };
51
- };
52
- const writeJsoncSync = (path, data, options = {}) => {
53
- const { detectIndent, formattingOptions, indent: indentOption, preserveComments = true, replacer, ...writeOptions } = { indent: " ", ...options };
54
- const { existingText, indent, trailingNewline } = readExistingSync(path, detectIndent, indentOption);
55
- const output = buildJsoncOutput(existingText, data, preserveComments, indent, trailingNewline, formattingOptions, replacer);
56
- writeFileSync(path, output, writeOptions);
57
- };
58
-
59
- export { writeJsoncSync as default };
@@ -1,8 +0,0 @@
1
- import { stringify } from 'smol-toml';
2
- import writeFile from './writeFile-B8HX0JIQ.js';
3
-
4
- const writeToml = async (path, data, options) => {
5
- await writeFile(path, stringify(data), options);
6
- };
7
-
8
- export { writeToml as default };
@@ -1,8 +0,0 @@
1
- import { stringify } from 'smol-toml';
2
- import writeFileSync from './writeFileSync-DB8vv8xR.js';
3
-
4
- const writeTomlSync = (path, data, options) => {
5
- writeFileSync(path, stringify(data), options);
6
- };
7
-
8
- export { writeTomlSync as default };
@@ -1,24 +0,0 @@
1
- import { stringify } from 'yaml';
2
- import writeFile from './writeFile-B8HX0JIQ.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") {
13
- stringifyOptions = options;
14
- effectiveReplacer = replacer;
15
- space = stringifyOptions.space;
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 };