@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,65 +0,0 @@
1
- 'use strict';
2
-
3
- const promises = require('node:fs/promises');
4
- const node_url = require('node:url');
5
- const path = require('@visulima/path');
6
- const utils = require('@visulima/path/utils');
7
- const F_OK = require('./F_OK-CWSqQIdF.cjs');
8
-
9
- var __defProp = Object.defineProperty;
10
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
- const findUp = /* @__PURE__ */ __name(async (name, options = {}) => {
12
- if (typeof name !== "string" && !Array.isArray(name) && typeof name !== "function") {
13
- throw new TypeError("The `name` argument must be of type `string` or `string[]`");
14
- }
15
- const cwd = options.cwd ? utils.toPath(options.cwd) : process.cwd();
16
- let directory = path.resolve(cwd);
17
- const { root } = path.parse(directory);
18
- const stopPath = utils.toPath(options.stopAt ?? root);
19
- const stopAt = path.resolve(directory, stopPath);
20
- const type = options.type ?? "file";
21
- const getMatchers = /* @__PURE__ */ __name(async function(currentDirectory) {
22
- if (typeof name === "function") {
23
- const match = await name(currentDirectory);
24
- return [match];
25
- }
26
- if (typeof name === "string") {
27
- return [name];
28
- }
29
- if (Array.isArray(name)) {
30
- return name;
31
- }
32
- return [name];
33
- }, "getMatchers");
34
- if (options.allowSymlinks === void 0) {
35
- options.allowSymlinks = true;
36
- }
37
- const statFunction = options.allowSymlinks ? promises.stat : promises.lstat;
38
- while (directory && directory !== stopAt && directory !== root) {
39
- for await (let fileName of await getMatchers(directory)) {
40
- if (fileName === F_OK.FIND_UP_STOP) {
41
- return void 0;
42
- }
43
- if (fileName === void 0) {
44
- continue;
45
- }
46
- if (Buffer.isBuffer(fileName)) {
47
- fileName = fileName.toString();
48
- } else if (fileName instanceof URL) {
49
- fileName = node_url.fileURLToPath(fileName);
50
- }
51
- const filePath = path.isAbsolute(fileName) ? fileName : path.resolve(directory, fileName);
52
- try {
53
- const stats = await statFunction(filePath);
54
- if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) {
55
- return filePath;
56
- }
57
- } catch {
58
- }
59
- }
60
- directory = path.dirname(directory);
61
- }
62
- return void 0;
63
- }, "findUp");
64
-
65
- module.exports = findUp;
@@ -1,65 +0,0 @@
1
- 'use strict';
2
-
3
- const node_fs = require('node:fs');
4
- const node_url = require('node:url');
5
- const path = require('@visulima/path');
6
- const utils = require('@visulima/path/utils');
7
- const F_OK = require('./F_OK-CWSqQIdF.cjs');
8
-
9
- var __defProp = Object.defineProperty;
10
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
- const findUpSync = /* @__PURE__ */ __name((name, options = {}) => {
12
- if (typeof name !== "string" && !Array.isArray(name) && typeof name !== "function") {
13
- throw new TypeError("The `name` argument must be of type `string` or `string[]`");
14
- }
15
- const cwd = options.cwd ? utils.toPath(options.cwd) : process.cwd();
16
- let directory = path.resolve(cwd);
17
- const { root } = path.parse(directory);
18
- const stopPath = utils.toPath(options.stopAt ?? root);
19
- const stopAt = path.resolve(directory, stopPath);
20
- const type = options.type ?? "file";
21
- const getMatchers = /* @__PURE__ */ __name(function(currentDirectory) {
22
- if (typeof name === "function") {
23
- const match = name(currentDirectory);
24
- return [match];
25
- }
26
- if (typeof name === "string") {
27
- return [name];
28
- }
29
- if (Array.isArray(name)) {
30
- return name;
31
- }
32
- return [name];
33
- }, "getMatchers");
34
- if (options.allowSymlinks === void 0) {
35
- options.allowSymlinks = true;
36
- }
37
- const statFunction = options.allowSymlinks ? node_fs.statSync : node_fs.lstatSync;
38
- while (directory && directory !== stopAt && directory !== root) {
39
- for (let fileName of getMatchers(directory)) {
40
- if (fileName === F_OK.FIND_UP_STOP) {
41
- return void 0;
42
- }
43
- if (fileName === void 0) {
44
- continue;
45
- }
46
- if (Buffer.isBuffer(fileName)) {
47
- fileName = fileName.toString();
48
- } else if (fileName instanceof URL) {
49
- fileName = node_url.fileURLToPath(fileName);
50
- }
51
- const filePath = path.isAbsolute(fileName) ? fileName : path.resolve(directory, fileName);
52
- try {
53
- const stats = statFunction(filePath);
54
- if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) {
55
- return filePath;
56
- }
57
- } catch {
58
- }
59
- }
60
- directory = path.dirname(directory);
61
- }
62
- return void 0;
63
- }, "findUpSync");
64
-
65
- module.exports = findUpSync;
@@ -1,63 +0,0 @@
1
- import { statSync, lstatSync } from 'node:fs';
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 findUpSync = /* @__PURE__ */ __name((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(function(currentDirectory) {
20
- if (typeof name === "function") {
21
- const match = 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 ? statSync : lstatSync;
36
- while (directory && directory !== stopAt && directory !== root) {
37
- for (let fileName of 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 = 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
- }, "findUpSync");
62
-
63
- export { findUpSync as default };
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- const getFileInfoType = /* @__PURE__ */ __name((fileInfo) => {
6
- if (fileInfo.isFile()) {
7
- return "file";
8
- }
9
- if (fileInfo.isDirectory()) {
10
- return "dir";
11
- }
12
- if (fileInfo.isSymbolicLink()) {
13
- return "symlink";
14
- }
15
- return void 0;
16
- }, "getFileInfoType");
17
-
18
- exports.getFileInfoType = getFileInfoType;
@@ -1,16 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- const getFileInfoType = /* @__PURE__ */ __name((fileInfo) => {
4
- if (fileInfo.isFile()) {
5
- return "file";
6
- }
7
- if (fileInfo.isDirectory()) {
8
- return "dir";
9
- }
10
- if (fileInfo.isSymbolicLink()) {
11
- return "symlink";
12
- }
13
- return void 0;
14
- }, "getFileInfoType");
15
-
16
- export { getFileInfoType as g };
@@ -1,110 +0,0 @@
1
- 'use strict';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- const INDENT_REGEX = /^(?:( )+|\t+)/;
6
- const INDENT_TYPE_SPACE = "space";
7
- const INDENT_TYPE_TAB = "tab";
8
- function makeIndentsMap(string, ignoreSingleSpaces) {
9
- const indents = /* @__PURE__ */ new Map();
10
- let previousSize = 0;
11
- let previousIndentType;
12
- let key;
13
- for (const line of string.split(/\n/g)) {
14
- if (!line) {
15
- continue;
16
- }
17
- let indent;
18
- let indentType;
19
- let use;
20
- let weight;
21
- let entry;
22
- const matches = line.match(INDENT_REGEX);
23
- if (matches === null) {
24
- previousSize = 0;
25
- previousIndentType = "";
26
- } else {
27
- indent = matches[0].length;
28
- indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
29
- if (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {
30
- continue;
31
- }
32
- if (indentType !== previousIndentType) {
33
- previousSize = 0;
34
- }
35
- previousIndentType = indentType;
36
- use = 1;
37
- weight = 0;
38
- const indentDifference = indent - previousSize;
39
- previousSize = indent;
40
- if (indentDifference === 0) {
41
- use = 0;
42
- weight = 1;
43
- } else {
44
- const absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;
45
- key = encodeIndentsKey(indentType, absoluteIndentDifference);
46
- }
47
- entry = indents.get(key);
48
- entry = entry === void 0 ? [1, 0] : [entry[0] + use, entry[1] + weight];
49
- indents.set(key, entry);
50
- }
51
- }
52
- return indents;
53
- }
54
- __name(makeIndentsMap, "makeIndentsMap");
55
- function encodeIndentsKey(indentType, indentAmount) {
56
- const typeCharacter = indentType === INDENT_TYPE_SPACE ? "s" : "t";
57
- return typeCharacter + String(indentAmount);
58
- }
59
- __name(encodeIndentsKey, "encodeIndentsKey");
60
- function decodeIndentsKey(indentsKey) {
61
- const keyHasTypeSpace = indentsKey[0] === "s";
62
- const type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
63
- const amount = Number(indentsKey.slice(1));
64
- return { type, amount };
65
- }
66
- __name(decodeIndentsKey, "decodeIndentsKey");
67
- function getMostUsedKey(indents) {
68
- let result;
69
- let maxUsed = 0;
70
- let maxWeight = 0;
71
- for (const [key, [usedCount, weight]] of indents) {
72
- if (usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) {
73
- maxUsed = usedCount;
74
- maxWeight = weight;
75
- result = key;
76
- }
77
- }
78
- return result;
79
- }
80
- __name(getMostUsedKey, "getMostUsedKey");
81
- function makeIndentString(type, amount) {
82
- const indentCharacter = type === INDENT_TYPE_SPACE ? " " : " ";
83
- return indentCharacter.repeat(amount);
84
- }
85
- __name(makeIndentString, "makeIndentString");
86
- function detectIndent(string) {
87
- if (typeof string !== "string") {
88
- throw new TypeError("Expected a string");
89
- }
90
- let indents = makeIndentsMap(string, true);
91
- if (indents.size === 0) {
92
- indents = makeIndentsMap(string, false);
93
- }
94
- const keyOfMostUsedIndent = getMostUsedKey(indents);
95
- let type;
96
- let amount = 0;
97
- let indent = "";
98
- if (keyOfMostUsedIndent !== void 0) {
99
- ({ type, amount } = decodeIndentsKey(keyOfMostUsedIndent));
100
- indent = makeIndentString(type, amount);
101
- }
102
- return {
103
- amount,
104
- type,
105
- indent
106
- };
107
- }
108
- __name(detectIndent, "detectIndent");
109
-
110
- exports.detectIndent = detectIndent;
@@ -1,108 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- const INDENT_REGEX = /^(?:( )+|\t+)/;
4
- const INDENT_TYPE_SPACE = "space";
5
- const INDENT_TYPE_TAB = "tab";
6
- function makeIndentsMap(string, ignoreSingleSpaces) {
7
- const indents = /* @__PURE__ */ new Map();
8
- let previousSize = 0;
9
- let previousIndentType;
10
- let key;
11
- for (const line of string.split(/\n/g)) {
12
- if (!line) {
13
- continue;
14
- }
15
- let indent;
16
- let indentType;
17
- let use;
18
- let weight;
19
- let entry;
20
- const matches = line.match(INDENT_REGEX);
21
- if (matches === null) {
22
- previousSize = 0;
23
- previousIndentType = "";
24
- } else {
25
- indent = matches[0].length;
26
- indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
27
- if (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {
28
- continue;
29
- }
30
- if (indentType !== previousIndentType) {
31
- previousSize = 0;
32
- }
33
- previousIndentType = indentType;
34
- use = 1;
35
- weight = 0;
36
- const indentDifference = indent - previousSize;
37
- previousSize = indent;
38
- if (indentDifference === 0) {
39
- use = 0;
40
- weight = 1;
41
- } else {
42
- const absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;
43
- key = encodeIndentsKey(indentType, absoluteIndentDifference);
44
- }
45
- entry = indents.get(key);
46
- entry = entry === void 0 ? [1, 0] : [entry[0] + use, entry[1] + weight];
47
- indents.set(key, entry);
48
- }
49
- }
50
- return indents;
51
- }
52
- __name(makeIndentsMap, "makeIndentsMap");
53
- function encodeIndentsKey(indentType, indentAmount) {
54
- const typeCharacter = indentType === INDENT_TYPE_SPACE ? "s" : "t";
55
- return typeCharacter + String(indentAmount);
56
- }
57
- __name(encodeIndentsKey, "encodeIndentsKey");
58
- function decodeIndentsKey(indentsKey) {
59
- const keyHasTypeSpace = indentsKey[0] === "s";
60
- const type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
61
- const amount = Number(indentsKey.slice(1));
62
- return { type, amount };
63
- }
64
- __name(decodeIndentsKey, "decodeIndentsKey");
65
- function getMostUsedKey(indents) {
66
- let result;
67
- let maxUsed = 0;
68
- let maxWeight = 0;
69
- for (const [key, [usedCount, weight]] of indents) {
70
- if (usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) {
71
- maxUsed = usedCount;
72
- maxWeight = weight;
73
- result = key;
74
- }
75
- }
76
- return result;
77
- }
78
- __name(getMostUsedKey, "getMostUsedKey");
79
- function makeIndentString(type, amount) {
80
- const indentCharacter = type === INDENT_TYPE_SPACE ? " " : " ";
81
- return indentCharacter.repeat(amount);
82
- }
83
- __name(makeIndentString, "makeIndentString");
84
- function detectIndent(string) {
85
- if (typeof string !== "string") {
86
- throw new TypeError("Expected a string");
87
- }
88
- let indents = makeIndentsMap(string, true);
89
- if (indents.size === 0) {
90
- indents = makeIndentsMap(string, false);
91
- }
92
- const keyOfMostUsedIndent = getMostUsedKey(indents);
93
- let type;
94
- let amount = 0;
95
- let indent = "";
96
- if (keyOfMostUsedIndent !== void 0) {
97
- ({ type, amount } = decodeIndentsKey(keyOfMostUsedIndent));
98
- indent = makeIndentString(type, amount);
99
- }
100
- return {
101
- amount,
102
- type,
103
- indent
104
- };
105
- }
106
- __name(detectIndent, "detectIndent");
107
-
108
- export { detectIndent as d };
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- const isStatsIdentical = /* @__PURE__ */ __name((sourceStat, destinationStat) => !!destinationStat.ino && !!destinationStat.dev && destinationStat.ino === sourceStat.ino && destinationStat.dev === sourceStat.dev, "isStatsIdentical");
6
-
7
- exports.isStatsIdentical = isStatsIdentical;
@@ -1,5 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- const isStatsIdentical = /* @__PURE__ */ __name((sourceStat, destinationStat) => !!destinationStat.ino && !!destinationStat.dev && destinationStat.ino === sourceStat.ino && destinationStat.dev === sourceStat.dev, "isStatsIdentical");
4
-
5
- export { isStatsIdentical as i };
@@ -1,20 +0,0 @@
1
- import { access } from 'node:fs/promises';
2
- import { toPath } from '@visulima/path/utils';
3
- import { F_OK } from './F_OK-JER1LjUr.mjs';
4
- import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
5
-
6
- var __defProp = Object.defineProperty;
7
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- async function isAccessible(path, mode = F_OK) {
9
- assertValidFileOrDirectoryPath(path);
10
- path = toPath(path);
11
- try {
12
- await access(path, mode);
13
- return true;
14
- } catch {
15
- return false;
16
- }
17
- }
18
- __name(isAccessible, "isAccessible");
19
-
20
- export { isAccessible as default };
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- const promises = require('node:fs/promises');
4
- const utils = require('@visulima/path/utils');
5
- const F_OK = require('./F_OK-CWSqQIdF.cjs');
6
- const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs');
7
-
8
- var __defProp = Object.defineProperty;
9
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
- async function isAccessible(path, mode = F_OK.F_OK) {
11
- assertValidFileOrDirectoryPath(path);
12
- path = utils.toPath(path);
13
- try {
14
- await promises.access(path, mode);
15
- return true;
16
- } catch {
17
- return false;
18
- }
19
- }
20
- __name(isAccessible, "isAccessible");
21
-
22
- module.exports = isAccessible;
@@ -1,20 +0,0 @@
1
- import { accessSync } from 'node:fs';
2
- import { toPath } from '@visulima/path/utils';
3
- import { F_OK } from './F_OK-JER1LjUr.mjs';
4
- import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-BWWgA1wj.mjs';
5
-
6
- var __defProp = Object.defineProperty;
7
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- function isAccessibleSync(path, mode = F_OK) {
9
- assertValidFileOrDirectoryPath(path);
10
- path = toPath(path);
11
- try {
12
- accessSync(path, mode);
13
- return true;
14
- } catch {
15
- return false;
16
- }
17
- }
18
- __name(isAccessibleSync, "isAccessibleSync");
19
-
20
- export { isAccessibleSync as default };
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- const node_fs = require('node:fs');
4
- const utils = require('@visulima/path/utils');
5
- const F_OK = require('./F_OK-CWSqQIdF.cjs');
6
- const assertValidFileOrDirectoryPath = require('./assertValidFileOrDirectoryPath-BMbgA-eI.cjs');
7
-
8
- var __defProp = Object.defineProperty;
9
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
- function isAccessibleSync(path, mode = F_OK.F_OK) {
11
- assertValidFileOrDirectoryPath(path);
12
- path = utils.toPath(path);
13
- try {
14
- node_fs.accessSync(path, mode);
15
- return true;
16
- } catch {
17
- return false;
18
- }
19
- }
20
- __name(isAccessibleSync, "isAccessibleSync");
21
-
22
- module.exports = isAccessibleSync;
@@ -1,114 +0,0 @@
1
- import { cwd } from 'node:process';
2
- import { toPath } from '@visulima/path/utils';
3
- import { mkdir, rename as rename$1, copyFile, unlink } from 'node:fs/promises';
4
- import { dirname, resolve } from '@visulima/path';
5
- import isAccessible from './isAccessible-Bonsm1Ez.mjs';
6
- import { mkdirSync, renameSync as renameSync$1, copyFileSync, unlinkSync } from 'node:fs';
7
- import isAccessibleSync from './isAccessibleSync-3gnUWUwX.mjs';
8
-
9
- var __defProp$3 = Object.defineProperty;
10
- var __name$3 = (target, value) => __defProp$3(target, "name", { value, configurable: true });
11
- class SameDirectoryError extends Error {
12
- static {
13
- __name$3(this, "SameDirectoryError");
14
- }
15
- constructor(source, destination) {
16
- super(`Source directory "${dirname(source)}" does not match destination directory "${dirname(destination)}"`);
17
- this.name = "SameDirectoryError";
18
- }
19
- }
20
- const validateSameDirectory = /* @__PURE__ */ __name$3((source, destination) => {
21
- if (!source || !destination) {
22
- throw new Error("Source and destination paths must not be empty");
23
- }
24
- if (dirname(source) !== dirname(destination)) {
25
- throw new SameDirectoryError(source, destination);
26
- }
27
- }, "validateSameDirectory");
28
-
29
- var __defProp$2 = Object.defineProperty;
30
- var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
31
- const internalMoveFile = /* @__PURE__ */ __name$2(async (sourcePath, destinationPath, { cwd, directoryMode, overwrite, validateDirectory }) => {
32
- if (cwd) {
33
- sourcePath = resolve(cwd, sourcePath);
34
- destinationPath = resolve(cwd, destinationPath);
35
- }
36
- if (validateDirectory) {
37
- validateSameDirectory(sourcePath, destinationPath);
38
- }
39
- if (!overwrite && await isAccessible(destinationPath)) {
40
- throw new Error(`The destination file exists: ${destinationPath}`);
41
- }
42
- await mkdir(dirname(destinationPath), {
43
- mode: directoryMode,
44
- recursive: true
45
- });
46
- try {
47
- await rename$1(sourcePath, destinationPath);
48
- } catch (error) {
49
- if (error.code === "EXDEV") {
50
- await copyFile(sourcePath, destinationPath);
51
- await unlink(sourcePath);
52
- } else {
53
- throw error;
54
- }
55
- }
56
- }, "internalMoveFile");
57
-
58
- var __defProp$1 = Object.defineProperty;
59
- var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
60
- const internalMoveFileSync = /* @__PURE__ */ __name$1((sourcePath, destinationPath, { cwd, directoryMode, overwrite, validateDirectory }) => {
61
- if (cwd) {
62
- sourcePath = resolve(cwd, sourcePath);
63
- destinationPath = resolve(cwd, destinationPath);
64
- }
65
- if (validateDirectory) {
66
- validateSameDirectory(sourcePath, destinationPath);
67
- }
68
- if (!overwrite && isAccessibleSync(destinationPath)) {
69
- throw new Error(`The destination file exists: ${destinationPath}`);
70
- }
71
- mkdirSync(dirname(destinationPath), {
72
- mode: directoryMode,
73
- recursive: true
74
- });
75
- try {
76
- renameSync$1(sourcePath, destinationPath);
77
- } catch (error) {
78
- if (error.code === "EXDEV") {
79
- copyFileSync(sourcePath, destinationPath);
80
- unlinkSync(sourcePath);
81
- } else {
82
- throw error;
83
- }
84
- }
85
- }, "internalMoveFileSync");
86
-
87
- var __defProp = Object.defineProperty;
88
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
89
- const move = /* @__PURE__ */ __name(async (sourcePath, destinationPath, options = {}) => {
90
- const internalOptions = {
91
- overwrite: true,
92
- validateDirectory: false,
93
- ...options,
94
- cwd: options.cwd ? toPath(options.cwd) : cwd()
95
- };
96
- await internalMoveFile(sourcePath, destinationPath, internalOptions);
97
- }, "move");
98
- const moveSync = /* @__PURE__ */ __name((sourcePath, destinationPath, options) => {
99
- const internalOptions = { overwrite: true, validateDirectory: false, ...options };
100
- internalOptions.cwd = internalOptions.cwd ? toPath(internalOptions.cwd) : cwd();
101
- internalMoveFileSync(sourcePath, destinationPath, internalOptions);
102
- }, "moveSync");
103
- const rename = /* @__PURE__ */ __name(async (source, destination, options) => {
104
- const internalOptions = { overwrite: true, ...options, validateDirectory: true };
105
- internalOptions.cwd = internalOptions.cwd ? toPath(internalOptions.cwd) : cwd();
106
- await internalMoveFile(source, destination, internalOptions);
107
- }, "rename");
108
- const renameSync = /* @__PURE__ */ __name((source, destination, options) => {
109
- const internalOptions = { overwrite: true, ...options, validateDirectory: true };
110
- internalOptions.cwd = internalOptions.cwd ? toPath(internalOptions.cwd) : cwd();
111
- internalMoveFileSync(source, destination, internalOptions);
112
- }, "renameSync");
113
-
114
- export { move, moveSync, rename, renameSync };