@visulima/fs 3.1.7 → 3.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +153 -153
  3. package/dist/eol.cjs +3 -28
  4. package/dist/eol.mjs +3 -20
  5. package/dist/error.cjs +1 -21
  6. package/dist/error.mjs +1 -7
  7. package/dist/index.cjs +1 -80
  8. package/dist/index.mjs +1 -31
  9. package/dist/packem_shared/AlreadyExistsError-CEu6_Tjb.mjs +1 -0
  10. package/dist/packem_shared/AlreadyExistsError-GC2XUgzJ.cjs +1 -0
  11. package/dist/packem_shared/DirectoryError-aGtmQVph.cjs +1 -0
  12. package/dist/packem_shared/DirectoryError-ddlbUV8C.mjs +1 -0
  13. package/dist/packem_shared/F_OK-7T91O6Oz.cjs +1 -0
  14. package/dist/packem_shared/F_OK-B71i3mUa.mjs +1 -0
  15. package/dist/packem_shared/JSONError-CVkb3xZ3.mjs +4 -0
  16. package/dist/packem_shared/JSONError-CWuiGmNc.cjs +4 -0
  17. package/dist/packem_shared/NotEmptyError-BWGfec5K.cjs +1 -0
  18. package/dist/packem_shared/NotEmptyError-DMh1o7UL.mjs +1 -0
  19. package/dist/packem_shared/NotFoundError-BPiW0icm.mjs +1 -0
  20. package/dist/packem_shared/NotFoundError-Diij7oqe.cjs +1 -0
  21. package/dist/packem_shared/PermissionError-B1Emi5a9.mjs +1 -0
  22. package/dist/packem_shared/PermissionError-Ck1Es7al.cjs +1 -0
  23. package/dist/packem_shared/WalkError-BsngoIKJ.mjs +1 -0
  24. package/dist/packem_shared/WalkError-gKgp0TWD.cjs +1 -0
  25. package/dist/packem_shared/assertValidFileContents-BZFnXa7K.mjs +1 -0
  26. package/dist/packem_shared/assertValidFileContents-CrbDz09d.cjs +1 -0
  27. package/dist/packem_shared/assertValidFileOrDirectoryPath-DgPIPmZT.mjs +1 -0
  28. package/dist/packem_shared/assertValidFileOrDirectoryPath-HOUs73Jk.cjs +1 -0
  29. package/dist/packem_shared/collect-Bl2Oc1qs.cjs +1 -0
  30. package/dist/packem_shared/collect-CyYPQFMs.mjs +1 -0
  31. package/dist/packem_shared/collectSync-BHjyXWq4.cjs +1 -0
  32. package/dist/packem_shared/collectSync-CD9cXw2g.mjs +1 -0
  33. package/dist/packem_shared/emptyDir-BdjO-6Gu.mjs +1 -0
  34. package/dist/packem_shared/emptyDir-DGRw4yE9.cjs +1 -0
  35. package/dist/packem_shared/emptyDirSync-C1vsMEp-.mjs +1 -0
  36. package/dist/packem_shared/emptyDirSync-DzjDZxOx.cjs +1 -0
  37. package/dist/packem_shared/ensureDir-BuIFF_6B.mjs +1 -0
  38. package/dist/packem_shared/ensureDir-DtQzyA70.cjs +1 -0
  39. package/dist/packem_shared/ensureDirSync-BuPHxdP4.mjs +1 -0
  40. package/dist/packem_shared/ensureDirSync-C8hIoS3o.cjs +1 -0
  41. package/dist/packem_shared/ensureFile-DcAODM6a.mjs +1 -0
  42. package/dist/packem_shared/ensureFile-wR8zBfXh.cjs +1 -0
  43. package/dist/packem_shared/ensureFileSync-BI1fIdNf.cjs +1 -0
  44. package/dist/packem_shared/ensureFileSync-CzPN6ucX.mjs +1 -0
  45. package/dist/packem_shared/ensureLink-BaZLXxgx.mjs +1 -0
  46. package/dist/packem_shared/ensureLink-DCPuU0Za.cjs +1 -0
  47. package/dist/packem_shared/ensureLinkSync-9C2JL-Sl.mjs +1 -0
  48. package/dist/packem_shared/ensureLinkSync-CuRZmQlV.cjs +1 -0
  49. package/dist/packem_shared/ensureSymlink-BH6wbylb.mjs +1 -0
  50. package/dist/packem_shared/ensureSymlink-J83jhdfA.cjs +1 -0
  51. package/dist/packem_shared/ensureSymlinkSync-CZSPodAm.mjs +1 -0
  52. package/dist/packem_shared/ensureSymlinkSync-VNtMTaV8.cjs +1 -0
  53. package/dist/packem_shared/findUp-C5aWsLuD.cjs +1 -0
  54. package/dist/packem_shared/findUp-CMGMYNty.mjs +1 -0
  55. package/dist/packem_shared/findUpSync-QP_ZEsJN.mjs +1 -0
  56. package/dist/packem_shared/findUpSync-U1lTgv4y.cjs +1 -0
  57. package/dist/packem_shared/get-file-info-type-CaWGXRjY.mjs +1 -0
  58. package/dist/packem_shared/get-file-info-type-DDbpRlDl.cjs +1 -0
  59. package/dist/packem_shared/index-BSjF-5vj.mjs +1 -0
  60. package/dist/packem_shared/index-DPla58ce.cjs +1 -0
  61. package/dist/packem_shared/is-stats-identical-Bti7K05l.cjs +1 -0
  62. package/dist/packem_shared/is-stats-identical-CohsLtWy.mjs +1 -0
  63. package/dist/packem_shared/isAccessible-BQZd1_xn.cjs +1 -0
  64. package/dist/packem_shared/isAccessible-CL4eE5VL.mjs +1 -0
  65. package/dist/packem_shared/isAccessibleSync-BP5N8k_-.cjs +1 -0
  66. package/dist/packem_shared/isAccessibleSync-_HU_ppdG.mjs +1 -0
  67. package/dist/packem_shared/move--o4NZLpD.mjs +1 -0
  68. package/dist/packem_shared/move-DwG6APiG.cjs +1 -0
  69. package/dist/packem_shared/parseJson-B_GwHpKj.cjs +6 -0
  70. package/dist/packem_shared/parseJson-Bqic0nN8.mjs +6 -0
  71. package/dist/packem_shared/readFile-BvefDyr_.cjs +1 -0
  72. package/dist/packem_shared/readFile-Cix_ijtX.mjs +1 -0
  73. package/dist/packem_shared/readFileSync-B0O-8BH0.mjs +1 -0
  74. package/dist/packem_shared/readFileSync-Ct8Ql4Vs.cjs +1 -0
  75. package/dist/packem_shared/readJson-BLvd2Bsj.mjs +1 -0
  76. package/dist/packem_shared/readJson-cP5ArpPg.cjs +1 -0
  77. package/dist/packem_shared/readJsonSync-B6h6A3Un.cjs +1 -0
  78. package/dist/packem_shared/readJsonSync-Br5dHGAI.mjs +1 -0
  79. package/dist/packem_shared/readYaml-BOYTR5D1.mjs +1 -0
  80. package/dist/packem_shared/readYaml-BzMFDsYe.cjs +1 -0
  81. package/dist/packem_shared/readYamlSync-BbK0khJu.cjs +1 -0
  82. package/dist/packem_shared/readYamlSync-md9g88k7.mjs +1 -0
  83. package/dist/packem_shared/remove-CtnFqEpd.mjs +1 -0
  84. package/dist/packem_shared/remove-DPCf2Qdb.cjs +1 -0
  85. package/dist/packem_shared/removeSync-Cyriz7r8.cjs +1 -0
  86. package/dist/packem_shared/removeSync-DI-IjqVp.mjs +1 -0
  87. package/dist/packem_shared/resolve-symlink-target-BofZSDIc.mjs +1 -0
  88. package/dist/packem_shared/resolve-symlink-target-zilkQ_AU.cjs +1 -0
  89. package/dist/packem_shared/stripJsonComments-Cp5SNAB7.mjs +1 -0
  90. package/dist/packem_shared/stripJsonComments-CvZSDnYT.cjs +1 -0
  91. package/dist/packem_shared/to-uint-8-array-2-3EvGd7.cjs +1 -0
  92. package/dist/packem_shared/to-uint-8-array-DwgaTasY.mjs +1 -0
  93. package/dist/packem_shared/walk-BZTXbT87.mjs +1 -0
  94. package/dist/packem_shared/walk-DyN_HVFW.cjs +1 -0
  95. package/dist/packem_shared/walk-include-C9pVST87.mjs +1 -0
  96. package/dist/packem_shared/walk-include-DkK-WJl4.cjs +1 -0
  97. package/dist/packem_shared/walkSync-BHlEzV_m.mjs +1 -0
  98. package/dist/packem_shared/walkSync-Bqi7L2yG.cjs +1 -0
  99. package/dist/packem_shared/writeFile-COOAkvOE.mjs +1 -0
  100. package/dist/packem_shared/writeFile-CjgQEfur.cjs +1 -0
  101. package/dist/packem_shared/writeFileSync-CQuRHo9n.cjs +1 -0
  102. package/dist/packem_shared/writeFileSync-rhu-y_zx.mjs +1 -0
  103. package/dist/packem_shared/writeJson-BYT4WInm.mjs +4 -0
  104. package/dist/packem_shared/writeJson-CJIciZ_Q.cjs +4 -0
  105. package/dist/packem_shared/writeJsonSync-BIsrhRbV.cjs +4 -0
  106. package/dist/packem_shared/writeJsonSync-CLlXOFDm.mjs +4 -0
  107. package/dist/packem_shared/writeYaml-CjzVd0K-.mjs +1 -0
  108. package/dist/packem_shared/writeYaml-VmX1VKhN.cjs +1 -0
  109. package/dist/packem_shared/writeYamlSync-D9A9Ixe1.mjs +1 -0
  110. package/dist/packem_shared/writeYamlSync-DYsM6XBi.cjs +1 -0
  111. package/dist/size.cjs +1 -118
  112. package/dist/size.mjs +1 -109
  113. package/dist/utils.cjs +1 -19
  114. package/dist/utils.mjs +1 -6
  115. package/dist/yaml.cjs +1 -15
  116. package/dist/yaml.mjs +1 -4
  117. package/package.json +1 -1
  118. package/dist/packem_shared/AlreadyExistsError-DpxtwQot.cjs +0 -34
  119. package/dist/packem_shared/AlreadyExistsError-GK7J9fVA.mjs +0 -32
  120. package/dist/packem_shared/DirectoryError-D8FHcAqu.cjs +0 -34
  121. package/dist/packem_shared/DirectoryError-DByTWE7t.mjs +0 -32
  122. package/dist/packem_shared/F_OK-CWSqQIdF.cjs +0 -17
  123. package/dist/packem_shared/F_OK-JER1LjUr.mjs +0 -8
  124. package/dist/packem_shared/JSONError-5-wHnrxX.cjs +0 -34
  125. package/dist/packem_shared/JSONError-CaKt7MhC.mjs +0 -32
  126. package/dist/packem_shared/NotEmptyError-BCS_5pPt.cjs +0 -34
  127. package/dist/packem_shared/NotEmptyError-DCXooh5l.mjs +0 -32
  128. package/dist/packem_shared/NotFoundError-B_1nPl3K.cjs +0 -34
  129. package/dist/packem_shared/NotFoundError-CUdcC61I.mjs +0 -32
  130. package/dist/packem_shared/PermissionError-CqGMI9qC.mjs +0 -32
  131. package/dist/packem_shared/PermissionError-QFMKgk2l.cjs +0 -34
  132. package/dist/packem_shared/WalkError-B4-yr8Kk.cjs +0 -31
  133. package/dist/packem_shared/WalkError-DvEBTTaj.mjs +0 -29
  134. package/dist/packem_shared/assertValidFileContents-CRVvyM6b.cjs +0 -11
  135. package/dist/packem_shared/assertValidFileContents-Ox-ScfeK.mjs +0 -9
  136. package/dist/packem_shared/assertValidFileOrDirectoryPath-BMbgA-eI.cjs +0 -11
  137. package/dist/packem_shared/assertValidFileOrDirectoryPath-BWWgA1wj.mjs +0 -9
  138. package/dist/packem_shared/collect-3Paj1Vqw.mjs +0 -16
  139. package/dist/packem_shared/collect-DnfQeSOL.cjs +0 -18
  140. package/dist/packem_shared/collectSync-D4vym4QD.cjs +0 -18
  141. package/dist/packem_shared/collectSync-DwJLL8SD.mjs +0 -16
  142. package/dist/packem_shared/emptyDir-DcCfiNcf.cjs +0 -22
  143. package/dist/packem_shared/emptyDir-Dw5xSBox.mjs +0 -20
  144. package/dist/packem_shared/emptyDirSync-BWA4n6TB.cjs +0 -21
  145. package/dist/packem_shared/emptyDirSync-DMAaCiC_.mjs +0 -19
  146. package/dist/packem_shared/ensureDir-BOfUZlxG.cjs +0 -35
  147. package/dist/packem_shared/ensureDir-BnA_fY1A.mjs +0 -33
  148. package/dist/packem_shared/ensureDirSync-DHmWi3CF.cjs +0 -35
  149. package/dist/packem_shared/ensureDirSync-Dm4az3YF.mjs +0 -33
  150. package/dist/packem_shared/ensureFile-BKrJMHfr.mjs +0 -27
  151. package/dist/packem_shared/ensureFile-CeGryLJI.cjs +0 -29
  152. package/dist/packem_shared/ensureFileSync-B7THM1sN.cjs +0 -29
  153. package/dist/packem_shared/ensureFileSync-BnhFBXaR.mjs +0 -27
  154. package/dist/packem_shared/ensureLink-ChsWDTK5.mjs +0 -34
  155. package/dist/packem_shared/ensureLink-CrxLNmHE.cjs +0 -36
  156. package/dist/packem_shared/ensureLinkSync-CG-DTUoV.mjs +0 -34
  157. package/dist/packem_shared/ensureLinkSync-D8uMqLh4.cjs +0 -36
  158. package/dist/packem_shared/ensureSymlink-BwJ_QhzJ.mjs +0 -52
  159. package/dist/packem_shared/ensureSymlink-D_ieOVYa.cjs +0 -54
  160. package/dist/packem_shared/ensureSymlinkSync-BamG29QK.mjs +0 -56
  161. package/dist/packem_shared/ensureSymlinkSync-DTMvUYZD.cjs +0 -58
  162. package/dist/packem_shared/findUp-D5W-MTpT.mjs +0 -63
  163. package/dist/packem_shared/findUp-DVIYN2wV.cjs +0 -65
  164. package/dist/packem_shared/findUpSync-BOiVyUOx.cjs +0 -65
  165. package/dist/packem_shared/findUpSync-DL3NPCYg.mjs +0 -63
  166. package/dist/packem_shared/get-file-info-type-BlryFnpp.cjs +0 -18
  167. package/dist/packem_shared/get-file-info-type-ButUVD6d.mjs +0 -16
  168. package/dist/packem_shared/index-BVZL6YMm.cjs +0 -110
  169. package/dist/packem_shared/index-r9Pk9gBe.mjs +0 -108
  170. package/dist/packem_shared/is-stats-identical-BfdEfO6i.cjs +0 -7
  171. package/dist/packem_shared/is-stats-identical-ByTYZ2Aw.mjs +0 -5
  172. package/dist/packem_shared/isAccessible-Bonsm1Ez.mjs +0 -20
  173. package/dist/packem_shared/isAccessible-ZNVGsSb7.cjs +0 -22
  174. package/dist/packem_shared/isAccessibleSync-3gnUWUwX.mjs +0 -20
  175. package/dist/packem_shared/isAccessibleSync-VWjQa-US.cjs +0 -22
  176. package/dist/packem_shared/move-DgF7Ul9L.mjs +0 -114
  177. package/dist/packem_shared/move-Dh925GL9.cjs +0 -121
  178. package/dist/packem_shared/parseJson-BA7Xrggq.mjs +0 -248
  179. package/dist/packem_shared/parseJson-LgPGI5ic.cjs +0 -250
  180. package/dist/packem_shared/readFile-b7UBVv17.mjs +0 -46
  181. package/dist/packem_shared/readFile-iFUhZHnh.cjs +0 -48
  182. package/dist/packem_shared/readFileSync-B3NTOR-W.cjs +0 -33
  183. package/dist/packem_shared/readFileSync-CkEJBqZB.mjs +0 -31
  184. package/dist/packem_shared/readJson-CEBHyuYq.cjs +0 -27
  185. package/dist/packem_shared/readJson-Ce9b06cu.mjs +0 -25
  186. package/dist/packem_shared/readJsonSync-B22hej0y.cjs +0 -27
  187. package/dist/packem_shared/readJsonSync-CkUI9_z5.mjs +0 -25
  188. package/dist/packem_shared/readYaml-C5MSs2GE.mjs +0 -13
  189. package/dist/packem_shared/readYaml-sR4bqUel.cjs +0 -15
  190. package/dist/packem_shared/readYamlSync-C3oOzxiN.cjs +0 -15
  191. package/dist/packem_shared/readYamlSync-CPjA-DLv.mjs +0 -13
  192. package/dist/packem_shared/remove-B2nxUObP.mjs +0 -18
  193. package/dist/packem_shared/remove-BpDiVPns.cjs +0 -20
  194. package/dist/packem_shared/removeSync-BosXW624.cjs +0 -20
  195. package/dist/packem_shared/removeSync-C87yepDI.mjs +0 -18
  196. package/dist/packem_shared/resolve-symlink-target-BbpEHdU2.mjs +0 -18
  197. package/dist/packem_shared/resolve-symlink-target-DImIddt6.cjs +0 -20
  198. package/dist/packem_shared/stripJsonComments-B66nRaTZ.mjs +0 -21
  199. package/dist/packem_shared/stripJsonComments-eDrcJvBT.cjs +0 -23
  200. package/dist/packem_shared/to-uint-8-array-B4CjMOD3.mjs +0 -21
  201. package/dist/packem_shared/to-uint-8-array-BaTEyX3D.cjs +0 -23
  202. package/dist/packem_shared/walk-CI3ygmrw.cjs +0 -100
  203. package/dist/packem_shared/walk-D7YA43g8.mjs +0 -98
  204. package/dist/packem_shared/walk-include-CMUSRa86.mjs +0 -20
  205. package/dist/packem_shared/walk-include-yUdRrF16.cjs +0 -23
  206. package/dist/packem_shared/walkSync-DLTsnwuJ.mjs +0 -103
  207. package/dist/packem_shared/walkSync-oXkmn9ZA.cjs +0 -105
  208. package/dist/packem_shared/writeFile-BZ4JBQxc.mjs +0 -58
  209. package/dist/packem_shared/writeFile-DgCFRCe5.cjs +0 -60
  210. package/dist/packem_shared/writeFileSync-Ctw5pNQH.mjs +0 -58
  211. package/dist/packem_shared/writeFileSync-DzXhx1pF.cjs +0 -60
  212. package/dist/packem_shared/writeJson-Bh4sU1Ly.cjs +0 -33
  213. package/dist/packem_shared/writeJson-axO_14yL.mjs +0 -31
  214. package/dist/packem_shared/writeJsonSync-CzngmuKb.mjs +0 -31
  215. package/dist/packem_shared/writeJsonSync-HFdHjunl.cjs +0 -33
  216. package/dist/packem_shared/writeYaml-3XQT2qtb.cjs +0 -29
  217. package/dist/packem_shared/writeYaml-BSFEuWp2.mjs +0 -27
  218. package/dist/packem_shared/writeYamlSync-B6VcXXIb.mjs +0 -27
  219. package/dist/packem_shared/writeYamlSync-BZR3If9v.cjs +0 -29
@@ -1,33 +0,0 @@
1
- import { lstat, mkdir } from 'node:fs/promises';
2
- import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
3
- import { g as getFileInfoType } from './get-file-info-type-ButUVD6d.mjs';
4
-
5
- var __defProp = Object.defineProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- const ensureDir = /* @__PURE__ */ __name(async (directory) => {
8
- assertValidFileOrDirectoryPath(directory);
9
- try {
10
- const fileInfo = await lstat(directory);
11
- if (!fileInfo.isDirectory()) {
12
- throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
13
- }
14
- return;
15
- } catch (error) {
16
- if (error.code !== "ENOENT") {
17
- throw error;
18
- }
19
- }
20
- try {
21
- await mkdir(directory, { recursive: true });
22
- } catch (error) {
23
- if (error.code !== "EEXIST") {
24
- throw error;
25
- }
26
- const fileInfo = await lstat(directory);
27
- if (!fileInfo.isDirectory()) {
28
- throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
29
- }
30
- }
31
- }, "ensureDir");
32
-
33
- export { ensureDir as default };
@@ -1,35 +0,0 @@
1
- 'use strict';
2
-
3
- const node_fs = require('node:fs');
4
- const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs');
5
- const getFileInfoType = require('./get-file-info-type-BlryFnpp.cjs');
6
-
7
- var __defProp = Object.defineProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- const ensureDirSync = /* @__PURE__ */ __name((directory) => {
10
- assertValidFileOrDirectoryPath(directory);
11
- try {
12
- const fileInfo = node_fs.lstatSync(directory);
13
- if (!fileInfo.isDirectory()) {
14
- throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType.getFileInfoType(fileInfo)}'`);
15
- }
16
- return;
17
- } catch (error) {
18
- if (error.code !== "ENOENT") {
19
- throw error;
20
- }
21
- }
22
- try {
23
- node_fs.mkdirSync(directory, { recursive: true });
24
- } catch (error) {
25
- if (error.code !== "EEXIST") {
26
- throw error;
27
- }
28
- const fileInfo = node_fs.lstatSync(directory);
29
- if (!fileInfo.isDirectory()) {
30
- throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType.getFileInfoType(fileInfo)}'`);
31
- }
32
- }
33
- }, "ensureDirSync");
34
-
35
- module.exports = ensureDirSync;
@@ -1,33 +0,0 @@
1
- import { lstatSync, mkdirSync } from 'node:fs';
2
- import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
3
- import { g as getFileInfoType } from './get-file-info-type-ButUVD6d.mjs';
4
-
5
- var __defProp = Object.defineProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- const ensureDirSync = /* @__PURE__ */ __name((directory) => {
8
- assertValidFileOrDirectoryPath(directory);
9
- try {
10
- const fileInfo = lstatSync(directory);
11
- if (!fileInfo.isDirectory()) {
12
- throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
13
- }
14
- return;
15
- } catch (error) {
16
- if (error.code !== "ENOENT") {
17
- throw error;
18
- }
19
- }
20
- try {
21
- mkdirSync(directory, { recursive: true });
22
- } catch (error) {
23
- if (error.code !== "EEXIST") {
24
- throw error;
25
- }
26
- const fileInfo = lstatSync(directory);
27
- if (!fileInfo.isDirectory()) {
28
- throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
29
- }
30
- }
31
- }, "ensureDirSync");
32
-
33
- export { ensureDirSync as default };
@@ -1,27 +0,0 @@
1
- import { lstat, writeFile } from 'node:fs/promises';
2
- import { dirname } from '@visulima/path';
3
- import { toPath } from '@visulima/path/utils';
4
- import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
5
- import ensureDir from './ensureDir-BnA_fY1A.mjs';
6
- import { g as getFileInfoType } from './get-file-info-type-ButUVD6d.mjs';
7
-
8
- var __defProp = Object.defineProperty;
9
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
- const ensureFile = /* @__PURE__ */ __name(async (filePath) => {
11
- assertValidFileOrDirectoryPath(filePath);
12
- try {
13
- const stat = await lstat(filePath);
14
- if (!stat.isFile()) {
15
- throw new Error(`Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`);
16
- }
17
- } catch (error) {
18
- if (error.code === "ENOENT") {
19
- await ensureDir(dirname(toPath(filePath)));
20
- await writeFile(filePath, new Uint8Array());
21
- return;
22
- }
23
- throw error;
24
- }
25
- }, "ensureFile");
26
-
27
- export { ensureFile as default };
@@ -1,29 +0,0 @@
1
- 'use strict';
2
-
3
- const promises = require('node:fs/promises');
4
- const path = require('@visulima/path');
5
- const utils = require('@visulima/path/utils');
6
- const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs');
7
- const ensureDir = require('./ensureDir-BOfUZlxG.cjs');
8
- const getFileInfoType = require('./get-file-info-type-BlryFnpp.cjs');
9
-
10
- var __defProp = Object.defineProperty;
11
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
12
- const ensureFile = /* @__PURE__ */ __name(async (filePath) => {
13
- assertValidFileOrDirectoryPath(filePath);
14
- try {
15
- const stat = await promises.lstat(filePath);
16
- if (!stat.isFile()) {
17
- throw new Error(`Ensure path exists, expected 'file', got '${getFileInfoType.getFileInfoType(stat)}'`);
18
- }
19
- } catch (error) {
20
- if (error.code === "ENOENT") {
21
- await ensureDir(path.dirname(utils.toPath(filePath)));
22
- await promises.writeFile(filePath, new Uint8Array());
23
- return;
24
- }
25
- throw error;
26
- }
27
- }, "ensureFile");
28
-
29
- module.exports = ensureFile;
@@ -1,29 +0,0 @@
1
- 'use strict';
2
-
3
- const node_fs = require('node:fs');
4
- const path = require('@visulima/path');
5
- const utils = require('@visulima/path/utils');
6
- const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs');
7
- const ensureDirSync = require('./ensureDirSync-DHmWi3CF.cjs');
8
- const getFileInfoType = require('./get-file-info-type-BlryFnpp.cjs');
9
-
10
- var __defProp = Object.defineProperty;
11
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
12
- const ensureFileSync = /* @__PURE__ */ __name((filePath) => {
13
- assertValidFileOrDirectoryPath(filePath);
14
- try {
15
- const stat = node_fs.lstatSync(filePath);
16
- if (!stat.isFile()) {
17
- throw new Error(`Ensure path exists, expected 'file', got '${getFileInfoType.getFileInfoType(stat)}'`);
18
- }
19
- } catch (error) {
20
- if (error.code === "ENOENT") {
21
- ensureDirSync(path.dirname(utils.toPath(filePath)));
22
- node_fs.writeFileSync(filePath, new Uint8Array());
23
- return;
24
- }
25
- throw error;
26
- }
27
- }, "ensureFileSync");
28
-
29
- module.exports = ensureFileSync;
@@ -1,27 +0,0 @@
1
- import { lstatSync, writeFileSync } from 'node:fs';
2
- import { dirname } from '@visulima/path';
3
- import { toPath } from '@visulima/path/utils';
4
- import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
5
- import ensureDirSync from './ensureDirSync-Dm4az3YF.mjs';
6
- import { g as getFileInfoType } from './get-file-info-type-ButUVD6d.mjs';
7
-
8
- var __defProp = Object.defineProperty;
9
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
- const ensureFileSync = /* @__PURE__ */ __name((filePath) => {
11
- assertValidFileOrDirectoryPath(filePath);
12
- try {
13
- const stat = lstatSync(filePath);
14
- if (!stat.isFile()) {
15
- throw new Error(`Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`);
16
- }
17
- } catch (error) {
18
- if (error.code === "ENOENT") {
19
- ensureDirSync(dirname(toPath(filePath)));
20
- writeFileSync(filePath, new Uint8Array());
21
- return;
22
- }
23
- throw error;
24
- }
25
- }, "ensureFileSync");
26
-
27
- export { ensureFileSync as default };
@@ -1,34 +0,0 @@
1
- import { lstat, link } from 'node:fs/promises';
2
- import { toNamespacedPath, dirname } from '@visulima/path';
3
- import { toPath } from '@visulima/path/utils';
4
- import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
5
- import ensureDir from './ensureDir-BnA_fY1A.mjs';
6
- import { i as isStatsIdentical } from './is-stats-identical-ByTYZ2Aw.mjs';
7
-
8
- var __defProp = Object.defineProperty;
9
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
- const ensureLink = /* @__PURE__ */ __name(async (source, destination) => {
11
- assertValidFileOrDirectoryPath(source);
12
- assertValidFileOrDirectoryPath(destination);
13
- source = toNamespacedPath(toPath(source));
14
- destination = toNamespacedPath(toPath(destination));
15
- let destinationStat;
16
- try {
17
- destinationStat = await lstat(destination);
18
- } catch {
19
- }
20
- let sourceStat;
21
- try {
22
- sourceStat = await lstat(source);
23
- } catch (error) {
24
- error.message = error.message.replace("lstat", "ensureLink");
25
- throw error;
26
- }
27
- if (destinationStat && isStatsIdentical(sourceStat, destinationStat)) {
28
- return;
29
- }
30
- await ensureDir(dirname(destination));
31
- await link(source, destination);
32
- }, "ensureLink");
33
-
34
- export { ensureLink as default };
@@ -1,36 +0,0 @@
1
- 'use strict';
2
-
3
- const promises = require('node:fs/promises');
4
- const path = require('@visulima/path');
5
- const utils = require('@visulima/path/utils');
6
- const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs');
7
- const ensureDir = require('./ensureDir-BOfUZlxG.cjs');
8
- const isStatsIdentical = require('./is-stats-identical-BfdEfO6i.cjs');
9
-
10
- var __defProp = Object.defineProperty;
11
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
12
- const ensureLink = /* @__PURE__ */ __name(async (source, destination) => {
13
- assertValidFileOrDirectoryPath(source);
14
- assertValidFileOrDirectoryPath(destination);
15
- source = path.toNamespacedPath(utils.toPath(source));
16
- destination = path.toNamespacedPath(utils.toPath(destination));
17
- let destinationStat;
18
- try {
19
- destinationStat = await promises.lstat(destination);
20
- } catch {
21
- }
22
- let sourceStat;
23
- try {
24
- sourceStat = await promises.lstat(source);
25
- } catch (error) {
26
- error.message = error.message.replace("lstat", "ensureLink");
27
- throw error;
28
- }
29
- if (destinationStat && isStatsIdentical.isStatsIdentical(sourceStat, destinationStat)) {
30
- return;
31
- }
32
- await ensureDir(path.dirname(destination));
33
- await promises.link(source, destination);
34
- }, "ensureLink");
35
-
36
- module.exports = ensureLink;
@@ -1,34 +0,0 @@
1
- import { lstatSync, linkSync } from 'node:fs';
2
- import { toNamespacedPath, dirname } from '@visulima/path';
3
- import { toPath } from '@visulima/path/utils';
4
- import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
5
- import ensureDirSync from './ensureDirSync-Dm4az3YF.mjs';
6
- import { i as isStatsIdentical } from './is-stats-identical-ByTYZ2Aw.mjs';
7
-
8
- var __defProp = Object.defineProperty;
9
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
- const ensureLinkSync = /* @__PURE__ */ __name((source, destination) => {
11
- assertValidFileOrDirectoryPath(source);
12
- assertValidFileOrDirectoryPath(destination);
13
- source = toNamespacedPath(toPath(source));
14
- destination = toNamespacedPath(toPath(destination));
15
- let destinationStat;
16
- try {
17
- destinationStat = lstatSync(destination);
18
- } catch {
19
- }
20
- let sourceStat;
21
- try {
22
- sourceStat = lstatSync(source);
23
- } catch (error) {
24
- error.message = error.message.replace("lstat", "ensureLink");
25
- throw error;
26
- }
27
- if (destinationStat && isStatsIdentical(sourceStat, destinationStat)) {
28
- return;
29
- }
30
- ensureDirSync(dirname(destination));
31
- linkSync(source, destination);
32
- }, "ensureLinkSync");
33
-
34
- export { ensureLinkSync as default };
@@ -1,36 +0,0 @@
1
- 'use strict';
2
-
3
- const node_fs = require('node:fs');
4
- const path = require('@visulima/path');
5
- const utils = require('@visulima/path/utils');
6
- const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs');
7
- const ensureDirSync = require('./ensureDirSync-DHmWi3CF.cjs');
8
- const isStatsIdentical = require('./is-stats-identical-BfdEfO6i.cjs');
9
-
10
- var __defProp = Object.defineProperty;
11
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
12
- const ensureLinkSync = /* @__PURE__ */ __name((source, destination) => {
13
- assertValidFileOrDirectoryPath(source);
14
- assertValidFileOrDirectoryPath(destination);
15
- source = path.toNamespacedPath(utils.toPath(source));
16
- destination = path.toNamespacedPath(utils.toPath(destination));
17
- let destinationStat;
18
- try {
19
- destinationStat = node_fs.lstatSync(destination);
20
- } catch {
21
- }
22
- let sourceStat;
23
- try {
24
- sourceStat = node_fs.lstatSync(source);
25
- } catch (error) {
26
- error.message = error.message.replace("lstat", "ensureLink");
27
- throw error;
28
- }
29
- if (destinationStat && isStatsIdentical.isStatsIdentical(sourceStat, destinationStat)) {
30
- return;
31
- }
32
- ensureDirSync(path.dirname(destination));
33
- node_fs.linkSync(source, destination);
34
- }, "ensureLinkSync");
35
-
36
- module.exports = ensureLinkSync;
@@ -1,52 +0,0 @@
1
- import { lstat, stat, symlink, readlink } from 'node:fs/promises';
2
- import { toNamespacedPath, dirname, resolve } from '@visulima/path';
3
- import { toPath } from '@visulima/path/utils';
4
- import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
5
- import ensureDir from './ensureDir-BnA_fY1A.mjs';
6
- import { g as getFileInfoType } from './get-file-info-type-ButUVD6d.mjs';
7
- import { i as isStatsIdentical } from './is-stats-identical-ByTYZ2Aw.mjs';
8
- import { r as resolveSymlinkTarget } from './resolve-symlink-target-BbpEHdU2.mjs';
9
- import AlreadyExistsError from './AlreadyExistsError-GK7J9fVA.mjs';
10
-
11
- var __defProp = Object.defineProperty;
12
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
13
- const isWindows = process.platform === "win32" || /^(?:msys|cygwin)$/.test(process.env.OSTYPE);
14
- const ensureSymlink = /* @__PURE__ */ __name(async (target, linkName, type) => {
15
- assertValidFileOrDirectoryPath(target);
16
- assertValidFileOrDirectoryPath(linkName);
17
- const targetRealPath = resolveSymlinkTarget(target, linkName);
18
- linkName = toNamespacedPath(toPath(linkName));
19
- try {
20
- const linkStatInfo = await lstat(linkName);
21
- if (linkStatInfo.isSymbolicLink() && // eslint-disable-next-line security/detect-non-literal-fs-filename
22
- isStatsIdentical(await stat(targetRealPath), await stat(linkName))) {
23
- const [sourceStat, destinationStat] = await Promise.all([stat(targetRealPath), stat(linkName)]);
24
- if (isStatsIdentical(sourceStat, destinationStat)) {
25
- return;
26
- }
27
- }
28
- } catch {
29
- }
30
- const sourceStatInfo = await lstat(targetRealPath);
31
- const sourceFilePathType = getFileInfoType(sourceStatInfo);
32
- await ensureDir(dirname(linkName));
33
- const symlinkType = type ?? (isWindows ? "junction" : sourceFilePathType === "dir" ? "dir" : "file");
34
- try {
35
- await symlink(toNamespacedPath(toPath(targetRealPath)), linkName, symlinkType);
36
- } catch (error) {
37
- if (error.code !== "EEXIST") {
38
- throw error;
39
- }
40
- const linkStatInfo = await lstat(linkName);
41
- if (!linkStatInfo.isSymbolicLink()) {
42
- throw new AlreadyExistsError("A " + getFileInfoType(linkStatInfo) + " already exists at the path: " + linkName);
43
- }
44
- const linkPath = await readlink(linkName);
45
- const linkRealPath = toNamespacedPath(resolve(linkPath));
46
- if (linkRealPath !== targetRealPath) {
47
- throw new AlreadyExistsError("A symlink targeting to an undesired path already exists: " + linkName + " -> " + linkRealPath);
48
- }
49
- }
50
- }, "ensureSymlink");
51
-
52
- export { ensureSymlink as default };
@@ -1,54 +0,0 @@
1
- 'use strict';
2
-
3
- const promises = require('node:fs/promises');
4
- const path = require('@visulima/path');
5
- const utils = require('@visulima/path/utils');
6
- const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs');
7
- const ensureDir = require('./ensureDir-BOfUZlxG.cjs');
8
- const getFileInfoType = require('./get-file-info-type-BlryFnpp.cjs');
9
- const isStatsIdentical = require('./is-stats-identical-BfdEfO6i.cjs');
10
- const resolveSymlinkTarget = require('./resolve-symlink-target-DImIddt6.cjs');
11
- const AlreadyExistsError = require('./AlreadyExistsError-DpxtwQot.cjs');
12
-
13
- var __defProp = Object.defineProperty;
14
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
- const isWindows = process.platform === "win32" || /^(?:msys|cygwin)$/.test(process.env.OSTYPE);
16
- const ensureSymlink = /* @__PURE__ */ __name(async (target, linkName, type) => {
17
- assertValidFileOrDirectoryPath(target);
18
- assertValidFileOrDirectoryPath(linkName);
19
- const targetRealPath = resolveSymlinkTarget.resolveSymlinkTarget(target, linkName);
20
- linkName = path.toNamespacedPath(utils.toPath(linkName));
21
- try {
22
- const linkStatInfo = await promises.lstat(linkName);
23
- if (linkStatInfo.isSymbolicLink() && // eslint-disable-next-line security/detect-non-literal-fs-filename
24
- isStatsIdentical.isStatsIdentical(await promises.stat(targetRealPath), await promises.stat(linkName))) {
25
- const [sourceStat, destinationStat] = await Promise.all([promises.stat(targetRealPath), promises.stat(linkName)]);
26
- if (isStatsIdentical.isStatsIdentical(sourceStat, destinationStat)) {
27
- return;
28
- }
29
- }
30
- } catch {
31
- }
32
- const sourceStatInfo = await promises.lstat(targetRealPath);
33
- const sourceFilePathType = getFileInfoType.getFileInfoType(sourceStatInfo);
34
- await ensureDir(path.dirname(linkName));
35
- const symlinkType = type ?? (isWindows ? "junction" : sourceFilePathType === "dir" ? "dir" : "file");
36
- try {
37
- await promises.symlink(path.toNamespacedPath(utils.toPath(targetRealPath)), linkName, symlinkType);
38
- } catch (error) {
39
- if (error.code !== "EEXIST") {
40
- throw error;
41
- }
42
- const linkStatInfo = await promises.lstat(linkName);
43
- if (!linkStatInfo.isSymbolicLink()) {
44
- throw new AlreadyExistsError("A " + getFileInfoType.getFileInfoType(linkStatInfo) + " already exists at the path: " + linkName);
45
- }
46
- const linkPath = await promises.readlink(linkName);
47
- const linkRealPath = path.toNamespacedPath(path.resolve(linkPath));
48
- if (linkRealPath !== targetRealPath) {
49
- throw new AlreadyExistsError("A symlink targeting to an undesired path already exists: " + linkName + " -> " + linkRealPath);
50
- }
51
- }
52
- }, "ensureSymlink");
53
-
54
- module.exports = ensureSymlink;
@@ -1,56 +0,0 @@
1
- import { lstatSync, statSync, symlinkSync, readlinkSync } from 'node:fs';
2
- import { toNamespacedPath, dirname, resolve } from '@visulima/path';
3
- import { toPath } from '@visulima/path/utils';
4
- import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
5
- import ensureDirSync from './ensureDirSync-Dm4az3YF.mjs';
6
- import { g as getFileInfoType } from './get-file-info-type-ButUVD6d.mjs';
7
- import { i as isStatsIdentical } from './is-stats-identical-ByTYZ2Aw.mjs';
8
- import { r as resolveSymlinkTarget } from './resolve-symlink-target-BbpEHdU2.mjs';
9
- import AlreadyExistsError from './AlreadyExistsError-GK7J9fVA.mjs';
10
-
11
- var __defProp = Object.defineProperty;
12
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
13
- const isWindows = process.platform === "win32" || /^(?:msys|cygwin)$/.test(process.env.OSTYPE);
14
- const ensureSymlinkSync = /* @__PURE__ */ __name((target, linkName, type) => {
15
- assertValidFileOrDirectoryPath(target);
16
- assertValidFileOrDirectoryPath(linkName);
17
- const targetRealPath = resolveSymlinkTarget(target, linkName);
18
- linkName = toNamespacedPath(toPath(linkName));
19
- try {
20
- const linkStatInfo = lstatSync(linkName);
21
- if (linkStatInfo.isSymbolicLink() && // eslint-disable-next-line security/detect-non-literal-fs-filename
22
- isStatsIdentical(statSync(targetRealPath), statSync(linkName))) {
23
- const sourceStat = statSync(targetRealPath);
24
- const destinationStat = statSync(linkName);
25
- if (isStatsIdentical(sourceStat, destinationStat)) {
26
- return;
27
- }
28
- }
29
- } catch {
30
- }
31
- const sourceStatInfo = lstatSync(targetRealPath);
32
- const sourceFilePathType = getFileInfoType(sourceStatInfo);
33
- ensureDirSync(dirname(linkName));
34
- const symlinkType = type ?? (isWindows ? "junction" : sourceFilePathType === "dir" ? "dir" : "file");
35
- try {
36
- symlinkSync(toNamespacedPath(toPath(targetRealPath)), linkName, symlinkType);
37
- } catch (error) {
38
- if (error.code !== "EEXIST") {
39
- throw error;
40
- }
41
- const linkStatInfo = lstatSync(linkName);
42
- if (!linkStatInfo.isSymbolicLink()) {
43
- throw new AlreadyExistsError("A " + getFileInfoType(linkStatInfo) + " already exists at the path: " + linkName);
44
- }
45
- const linkPath = readlinkSync(linkName);
46
- const linkRealPath = toNamespacedPath(resolve(linkPath));
47
- if (linkRealPath !== targetRealPath) {
48
- throw new AlreadyExistsError(
49
- // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
50
- "A symlink targeting to an undesired path already exists: " + linkName + " -> " + linkRealPath
51
- );
52
- }
53
- }
54
- }, "ensureSymlinkSync");
55
-
56
- export { ensureSymlinkSync as default };
@@ -1,58 +0,0 @@
1
- 'use strict';
2
-
3
- const node_fs = require('node:fs');
4
- const path = require('@visulima/path');
5
- const utils = require('@visulima/path/utils');
6
- const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs');
7
- const ensureDirSync = require('./ensureDirSync-DHmWi3CF.cjs');
8
- const getFileInfoType = require('./get-file-info-type-BlryFnpp.cjs');
9
- const isStatsIdentical = require('./is-stats-identical-BfdEfO6i.cjs');
10
- const resolveSymlinkTarget = require('./resolve-symlink-target-DImIddt6.cjs');
11
- const AlreadyExistsError = require('./AlreadyExistsError-DpxtwQot.cjs');
12
-
13
- var __defProp = Object.defineProperty;
14
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
- const isWindows = process.platform === "win32" || /^(?:msys|cygwin)$/.test(process.env.OSTYPE);
16
- const ensureSymlinkSync = /* @__PURE__ */ __name((target, linkName, type) => {
17
- assertValidFileOrDirectoryPath(target);
18
- assertValidFileOrDirectoryPath(linkName);
19
- const targetRealPath = resolveSymlinkTarget.resolveSymlinkTarget(target, linkName);
20
- linkName = path.toNamespacedPath(utils.toPath(linkName));
21
- try {
22
- const linkStatInfo = node_fs.lstatSync(linkName);
23
- if (linkStatInfo.isSymbolicLink() && // eslint-disable-next-line security/detect-non-literal-fs-filename
24
- isStatsIdentical.isStatsIdentical(node_fs.statSync(targetRealPath), node_fs.statSync(linkName))) {
25
- const sourceStat = node_fs.statSync(targetRealPath);
26
- const destinationStat = node_fs.statSync(linkName);
27
- if (isStatsIdentical.isStatsIdentical(sourceStat, destinationStat)) {
28
- return;
29
- }
30
- }
31
- } catch {
32
- }
33
- const sourceStatInfo = node_fs.lstatSync(targetRealPath);
34
- const sourceFilePathType = getFileInfoType.getFileInfoType(sourceStatInfo);
35
- ensureDirSync(path.dirname(linkName));
36
- const symlinkType = type ?? (isWindows ? "junction" : sourceFilePathType === "dir" ? "dir" : "file");
37
- try {
38
- node_fs.symlinkSync(path.toNamespacedPath(utils.toPath(targetRealPath)), linkName, symlinkType);
39
- } catch (error) {
40
- if (error.code !== "EEXIST") {
41
- throw error;
42
- }
43
- const linkStatInfo = node_fs.lstatSync(linkName);
44
- if (!linkStatInfo.isSymbolicLink()) {
45
- throw new AlreadyExistsError("A " + getFileInfoType.getFileInfoType(linkStatInfo) + " already exists at the path: " + linkName);
46
- }
47
- const linkPath = node_fs.readlinkSync(linkName);
48
- const linkRealPath = path.toNamespacedPath(path.resolve(linkPath));
49
- if (linkRealPath !== targetRealPath) {
50
- throw new AlreadyExistsError(
51
- // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
52
- "A symlink targeting to an undesired path already exists: " + linkName + " -> " + linkRealPath
53
- );
54
- }
55
- }
56
- }, "ensureSymlinkSync");
57
-
58
- module.exports = ensureSymlinkSync;
@@ -1,63 +0,0 @@
1
- import { stat, lstat } from 'node:fs/promises';
2
- import { fileURLToPath } from 'node:url';
3
- import { resolve, parse, isAbsolute, dirname } from '@visulima/path';
4
- import { toPath } from '@visulima/path/utils';
5
- import { FIND_UP_STOP } from './F_OK-JER1LjUr.mjs';
6
-
7
- var __defProp = Object.defineProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- const findUp = /* @__PURE__ */ __name(async (name, options = {}) => {
10
- if (typeof name !== "string" && !Array.isArray(name) && typeof name !== "function") {
11
- throw new TypeError("The `name` argument must be of type `string` or `string[]`");
12
- }
13
- const cwd = options.cwd ? toPath(options.cwd) : process.cwd();
14
- let directory = resolve(cwd);
15
- const { root } = parse(directory);
16
- const stopPath = toPath(options.stopAt ?? root);
17
- const stopAt = resolve(directory, stopPath);
18
- const type = options.type ?? "file";
19
- const getMatchers = /* @__PURE__ */ __name(async function(currentDirectory) {
20
- if (typeof name === "function") {
21
- const match = await name(currentDirectory);
22
- return [match];
23
- }
24
- if (typeof name === "string") {
25
- return [name];
26
- }
27
- if (Array.isArray(name)) {
28
- return name;
29
- }
30
- return [name];
31
- }, "getMatchers");
32
- if (options.allowSymlinks === void 0) {
33
- options.allowSymlinks = true;
34
- }
35
- const statFunction = options.allowSymlinks ? stat : lstat;
36
- while (directory && directory !== stopAt && directory !== root) {
37
- for await (let fileName of await getMatchers(directory)) {
38
- if (fileName === FIND_UP_STOP) {
39
- return void 0;
40
- }
41
- if (fileName === void 0) {
42
- continue;
43
- }
44
- if (Buffer.isBuffer(fileName)) {
45
- fileName = fileName.toString();
46
- } else if (fileName instanceof URL) {
47
- fileName = fileURLToPath(fileName);
48
- }
49
- const filePath = isAbsolute(fileName) ? fileName : resolve(directory, fileName);
50
- try {
51
- const stats = await statFunction(filePath);
52
- if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) {
53
- return filePath;
54
- }
55
- } catch {
56
- }
57
- }
58
- directory = dirname(directory);
59
- }
60
- return void 0;
61
- }, "findUp");
62
-
63
- export { findUp as default };