@idlebox/node 1.4.6 → 1.4.7

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 (332) hide show
  1. package/config/autoindex.json +4 -0
  2. package/config/rig.json +5 -0
  3. package/lib/{esm/asyncLoad.d.ts → asyncLoad.d.ts} +1 -5
  4. package/lib/asyncLoad.d.ts.map +1 -0
  5. package/lib/{esm/asyncLoad.js → asyncLoad.js} +4 -11
  6. package/lib/asyncLoad.js.map +1 -0
  7. package/lib/{esm/__create_index.generated.d.ts → autoindex.d.ts} +19 -16
  8. package/lib/autoindex.d.ts.map +1 -0
  9. package/lib/autoindex.generated.d.ts +80 -0
  10. package/lib/autoindex.generated.d.ts.map +1 -0
  11. package/lib/autoindex.generated.js +132 -0
  12. package/lib/autoindex.generated.js.map +1 -0
  13. package/lib/{esm/__create_index.generated.js → autoindex.js} +13 -7
  14. package/lib/autoindex.js.map +1 -0
  15. package/lib/child_process/error.d.ts.map +1 -0
  16. package/lib/{esm/child_process → child_process}/error.js +1 -1
  17. package/lib/child_process/error.js.map +1 -0
  18. package/lib/{esm/child_process → child_process}/execa.d.ts +6 -2
  19. package/lib/child_process/execa.d.ts.map +1 -0
  20. package/lib/{esm/child_process → child_process}/execa.js +8 -6
  21. package/lib/child_process/execa.js.map +1 -0
  22. package/lib/child_process/lateError.d.ts.map +1 -0
  23. package/lib/{esm/child_process → child_process}/lateError.js +1 -1
  24. package/lib/child_process/lateError.js.map +1 -0
  25. package/lib/{esm/child_process → child_process}/respawn.d.ts +2 -2
  26. package/lib/child_process/respawn.d.ts.map +1 -0
  27. package/lib/{esm/child_process → child_process}/respawn.js +7 -11
  28. package/lib/child_process/respawn.js.map +1 -0
  29. package/lib/cli-io/output.d.ts.map +1 -0
  30. package/lib/{esm/cli-io → cli-io}/output.js +1 -1
  31. package/lib/cli-io/output.js.map +1 -0
  32. package/lib/crypto/md5.d.ts.map +1 -0
  33. package/lib/{esm/crypto → crypto}/md5.js +1 -1
  34. package/lib/crypto/md5.js.map +1 -0
  35. package/lib/crypto/sha256.d.ts.map +1 -0
  36. package/lib/{esm/crypto → crypto}/sha256.js +1 -1
  37. package/lib/crypto/sha256.js.map +1 -0
  38. package/lib/environment/findBinary.d.ts +3 -0
  39. package/lib/environment/findBinary.d.ts.map +1 -0
  40. package/lib/{esm/environment → environment}/findBinary.js +1 -1
  41. package/lib/environment/findBinary.js.map +1 -0
  42. package/lib/environment/getEnvironment.d.ts.map +1 -0
  43. package/lib/{esm/environment → environment}/getEnvironment.js +3 -3
  44. package/lib/environment/getEnvironment.js.map +1 -0
  45. package/lib/environment/npmConfig.d.ts.map +1 -0
  46. package/lib/{esm/environment → environment}/npmConfig.js +1 -1
  47. package/lib/environment/npmConfig.js.map +1 -0
  48. package/lib/{esm/environment → environment}/pathEnvironment.d.ts +4 -0
  49. package/lib/environment/pathEnvironment.d.ts.map +1 -0
  50. package/lib/{esm/environment → environment}/pathEnvironment.js +8 -5
  51. package/lib/environment/pathEnvironment.js.map +1 -0
  52. package/lib/error/linux.d.ts.map +1 -0
  53. package/lib/{esm/error → error}/linux.js +1 -1
  54. package/lib/error/linux.js.map +1 -0
  55. package/lib/{esm/error → error}/types.d.ts +2 -2
  56. package/lib/error/types.d.ts.map +1 -0
  57. package/lib/{esm/error → error}/types.js +3 -2
  58. package/lib/error/types.js.map +1 -0
  59. package/lib/events/dumpEventEmitter.d.ts.map +1 -0
  60. package/lib/{esm/events → events}/dumpEventEmitter.js +1 -1
  61. package/lib/events/dumpEventEmitter.js.map +1 -0
  62. package/lib/fs/commandExists.d.ts.map +1 -0
  63. package/lib/{esm/fs → fs}/commandExists.js +3 -3
  64. package/lib/fs/commandExists.js.map +1 -0
  65. package/lib/fs/emptyDir.d.ts +10 -0
  66. package/lib/fs/emptyDir.d.ts.map +1 -0
  67. package/lib/{esm/fs → fs}/emptyDir.js +6 -3
  68. package/lib/fs/emptyDir.js.map +1 -0
  69. package/lib/fs/ensureDir.d.ts +3 -0
  70. package/lib/fs/ensureDir.d.ts.map +1 -0
  71. package/lib/fs/ensureDir.js +20 -0
  72. package/lib/fs/ensureDir.js.map +1 -0
  73. package/lib/fs/exists.d.ts.map +1 -0
  74. package/lib/{esm/fs → fs}/exists.js +1 -1
  75. package/lib/fs/exists.js.map +1 -0
  76. package/lib/fs/tempFolder.d.ts.map +1 -0
  77. package/lib/{esm/fs → fs}/tempFolder.js +1 -1
  78. package/lib/fs/tempFolder.js.map +1 -0
  79. package/lib/fs/weiteChanged.d.ts.map +1 -0
  80. package/lib/{esm/fs → fs}/weiteChanged.js +1 -1
  81. package/lib/fs/weiteChanged.js.map +1 -0
  82. package/lib/lifecycle/register.d.ts +10 -0
  83. package/lib/lifecycle/register.d.ts.map +1 -0
  84. package/lib/lifecycle/register.js +81 -0
  85. package/lib/lifecycle/register.js.map +1 -0
  86. package/lib/log/terminal.d.ts.map +1 -0
  87. package/lib/{esm/log → log}/terminal.js +1 -1
  88. package/lib/{cjs/log/terminal.cjs.map → log/terminal.js.map} +1 -10
  89. package/lib/path-resolve/findPackageRoot.d.ts.map +1 -0
  90. package/lib/{esm/path-resolve → path-resolve}/findPackageRoot.js +2 -2
  91. package/lib/path-resolve/findPackageRoot.js.map +1 -0
  92. package/lib/{esm/path-resolve → path-resolve}/findUp.d.ts +4 -4
  93. package/lib/path-resolve/findUp.d.ts.map +1 -0
  94. package/lib/path-resolve/findUp.js +118 -0
  95. package/lib/path-resolve/findUp.js.map +1 -0
  96. package/lib/path-resolve/getAllUp.d.ts.map +1 -0
  97. package/lib/{esm/path-resolve → path-resolve}/getAllUp.js +1 -1
  98. package/lib/path-resolve/getAllUp.js.map +1 -0
  99. package/lib/path-resolve/lrelative.d.ts.map +1 -0
  100. package/lib/{esm/path-resolve → path-resolve}/lrelative.js +1 -1
  101. package/lib/path-resolve/lrelative.js.map +1 -0
  102. package/lib/path-resolve/nodeResolvePathArray.d.ts.map +1 -0
  103. package/lib/{esm/path-resolve → path-resolve}/nodeResolvePathArray.js +1 -1
  104. package/lib/path-resolve/nodeResolvePathArray.js.map +1 -0
  105. package/lib/path-resolve/resolvePath.d.ts.map +1 -0
  106. package/lib/{esm/path-resolve → path-resolve}/resolvePath.js +1 -1
  107. package/lib/path-resolve/resolvePath.js.map +1 -0
  108. package/lib/preload.d.ts.map +1 -0
  109. package/lib/preload.js +2 -0
  110. package/lib/preload.js.map +1 -0
  111. package/lib/stream/blackHoleStream.d.ts.map +1 -0
  112. package/lib/{esm/stream → stream}/blackHoleStream.js +1 -1
  113. package/lib/stream/blackHoleStream.js.map +1 -0
  114. package/lib/stream/collectingStream.d.ts.map +1 -0
  115. package/lib/{esm/stream → stream}/collectingStream.js +1 -1
  116. package/lib/stream/collectingStream.js.map +1 -0
  117. package/lib/stream/disposableStream.d.ts.map +1 -0
  118. package/lib/{esm/stream → stream}/disposableStream.js +1 -1
  119. package/lib/stream/disposableStream.js.map +1 -0
  120. package/lib/stream/drainStream.d.ts.map +1 -0
  121. package/lib/{esm/stream → stream}/drainStream.js +1 -1
  122. package/lib/stream/drainStream.js.map +1 -0
  123. package/lib/stream/loggerStream.d.ts.map +1 -0
  124. package/lib/{esm/stream → stream}/loggerStream.js +1 -1
  125. package/lib/stream/loggerStream.js.map +1 -0
  126. package/lib/stream/streamPromise.d.ts.map +1 -0
  127. package/lib/{esm/stream → stream}/streamPromise.js +1 -1
  128. package/lib/stream/streamPromise.js.map +1 -0
  129. package/lib/tsconfig.tsbuildinfo +1 -0
  130. package/package.json +18 -32
  131. package/src/asyncLoad.ts +3 -12
  132. package/src/autoindex.generated.ts +159 -0
  133. package/src/autoindex.ts +153 -0
  134. package/src/child_process/execa.ts +14 -7
  135. package/src/child_process/respawn.ts +7 -12
  136. package/src/environment/findBinary.ts +2 -5
  137. package/src/environment/getEnvironment.ts +2 -2
  138. package/src/environment/pathEnvironment.ts +7 -4
  139. package/src/error/types.ts +3 -2
  140. package/src/fs/commandExists.ts +2 -2
  141. package/src/fs/emptyDir.ts +6 -3
  142. package/src/fs/ensureDir.ts +19 -0
  143. package/src/lifecycle/register.ts +97 -0
  144. package/src/path-resolve/findPackageRoot.ts +1 -1
  145. package/src/path-resolve/findUp.ts +105 -55
  146. package/src/tsconfig.json +4 -4
  147. package/tests/01-load/load.test.js +37 -0
  148. package/tests/01-load/module.js +8 -0
  149. package/tests/01-load/package.json +4 -0
  150. package/tests/01-load/require.cjs +7 -0
  151. package/tests/include/paths.js +3 -0
  152. package/tests/package.json +4 -0
  153. package/tests/respawn.js +12 -0
  154. package/lib/cjs/__create_index.generated.cjs +0 -186
  155. package/lib/cjs/__create_index.generated.cjs.map +0 -10
  156. package/lib/cjs/asyncLoad.cjs +0 -55
  157. package/lib/cjs/asyncLoad.cjs.map +0 -10
  158. package/lib/cjs/child_process/error.cjs +0 -45
  159. package/lib/cjs/child_process/error.cjs.map +0 -10
  160. package/lib/cjs/child_process/execa.cjs +0 -96
  161. package/lib/cjs/child_process/execa.cjs.map +0 -10
  162. package/lib/cjs/child_process/lateError.cjs +0 -76
  163. package/lib/cjs/child_process/lateError.cjs.map +0 -10
  164. package/lib/cjs/child_process/respawn.cjs +0 -123
  165. package/lib/cjs/child_process/respawn.cjs.map +0 -10
  166. package/lib/cjs/cli-io/output.cjs +0 -7
  167. package/lib/cjs/cli-io/output.cjs.map +0 -10
  168. package/lib/cjs/crypto/md5.cjs +0 -8
  169. package/lib/cjs/crypto/md5.cjs.map +0 -10
  170. package/lib/cjs/crypto/sha256.cjs +0 -8
  171. package/lib/cjs/crypto/sha256.cjs.map +0 -10
  172. package/lib/cjs/environment/findBinary.cjs +0 -15
  173. package/lib/cjs/environment/findBinary.cjs.map +0 -10
  174. package/lib/cjs/environment/getEnvironment.cjs +0 -55
  175. package/lib/cjs/environment/getEnvironment.cjs.map +0 -10
  176. package/lib/cjs/environment/npmConfig.cjs +0 -24
  177. package/lib/cjs/environment/npmConfig.cjs.map +0 -10
  178. package/lib/cjs/environment/pathEnvironment.cjs +0 -46
  179. package/lib/cjs/environment/pathEnvironment.cjs.map +0 -10
  180. package/lib/cjs/error/linux.cjs +0 -129
  181. package/lib/cjs/error/linux.cjs.map +0 -10
  182. package/lib/cjs/error/nodejs-error-code.generated.cjs +0 -2498
  183. package/lib/cjs/error/nodejs-error-code.generated.cjs.map +0 -10
  184. package/lib/cjs/error/types.cjs +0 -32
  185. package/lib/cjs/error/types.cjs.map +0 -10
  186. package/lib/cjs/events/dumpEventEmitter.cjs +0 -11
  187. package/lib/cjs/events/dumpEventEmitter.cjs.map +0 -10
  188. package/lib/cjs/fs/commandExists.cjs +0 -53
  189. package/lib/cjs/fs/commandExists.cjs.map +0 -10
  190. package/lib/cjs/fs/emptyDir.cjs +0 -30
  191. package/lib/cjs/fs/emptyDir.cjs.map +0 -10
  192. package/lib/cjs/fs/exists.cjs +0 -35
  193. package/lib/cjs/fs/exists.cjs.map +0 -10
  194. package/lib/cjs/fs/tempFolder.cjs +0 -54
  195. package/lib/cjs/fs/tempFolder.cjs.map +0 -10
  196. package/lib/cjs/fs/weiteChanged.cjs +0 -52
  197. package/lib/cjs/fs/weiteChanged.cjs.map +0 -10
  198. package/lib/cjs/log/terminal.cjs +0 -41
  199. package/lib/cjs/path-resolve/findPackageRoot.cjs +0 -23
  200. package/lib/cjs/path-resolve/findPackageRoot.cjs.map +0 -10
  201. package/lib/cjs/path-resolve/findUp.cjs +0 -72
  202. package/lib/cjs/path-resolve/findUp.cjs.map +0 -10
  203. package/lib/cjs/path-resolve/getAllUp.cjs +0 -17
  204. package/lib/cjs/path-resolve/getAllUp.cjs.map +0 -10
  205. package/lib/cjs/path-resolve/lrelative.cjs +0 -23
  206. package/lib/cjs/path-resolve/lrelative.cjs.map +0 -10
  207. package/lib/cjs/path-resolve/nodeResolvePathArray.cjs +0 -13
  208. package/lib/cjs/path-resolve/nodeResolvePathArray.cjs.map +0 -10
  209. package/lib/cjs/path-resolve/resolvePath.cjs +0 -27
  210. package/lib/cjs/path-resolve/resolvePath.cjs.map +0 -10
  211. package/lib/cjs/preload.cjs +0 -3
  212. package/lib/cjs/preload.cjs.map +0 -10
  213. package/lib/cjs/stream/blackHoleStream.cjs +0 -11
  214. package/lib/cjs/stream/blackHoleStream.cjs.map +0 -10
  215. package/lib/cjs/stream/collectingStream.cjs +0 -79
  216. package/lib/cjs/stream/collectingStream.cjs.map +0 -10
  217. package/lib/cjs/stream/disposableStream.cjs +0 -22
  218. package/lib/cjs/stream/disposableStream.cjs.map +0 -10
  219. package/lib/cjs/stream/drainStream.cjs +0 -18
  220. package/lib/cjs/stream/drainStream.cjs.map +0 -10
  221. package/lib/cjs/stream/loggerStream.cjs +0 -59
  222. package/lib/cjs/stream/loggerStream.cjs.map +0 -10
  223. package/lib/cjs/stream/streamPromise.cjs +0 -25
  224. package/lib/cjs/stream/streamPromise.cjs.map +0 -10
  225. package/lib/esm/__create_index.generated.d.ts.map +0 -10
  226. package/lib/esm/__create_index.generated.js.map +0 -10
  227. package/lib/esm/__virtual_tsconfig.tsbuildinfo +0 -1
  228. package/lib/esm/asyncLoad.d.ts.map +0 -10
  229. package/lib/esm/asyncLoad.js.map +0 -10
  230. package/lib/esm/child_process/error.d.ts.map +0 -10
  231. package/lib/esm/child_process/error.js.map +0 -10
  232. package/lib/esm/child_process/execa.d.ts.map +0 -10
  233. package/lib/esm/child_process/execa.js.map +0 -10
  234. package/lib/esm/child_process/lateError.d.ts.map +0 -10
  235. package/lib/esm/child_process/lateError.js.map +0 -10
  236. package/lib/esm/child_process/respawn.d.ts.map +0 -10
  237. package/lib/esm/child_process/respawn.js.map +0 -10
  238. package/lib/esm/cli-io/output.d.ts.map +0 -10
  239. package/lib/esm/cli-io/output.js.map +0 -10
  240. package/lib/esm/crypto/md5.d.ts.map +0 -10
  241. package/lib/esm/crypto/md5.js.map +0 -10
  242. package/lib/esm/crypto/sha256.d.ts.map +0 -10
  243. package/lib/esm/crypto/sha256.js.map +0 -10
  244. package/lib/esm/environment/findBinary.d.ts +0 -2
  245. package/lib/esm/environment/findBinary.d.ts.map +0 -10
  246. package/lib/esm/environment/findBinary.js.map +0 -10
  247. package/lib/esm/environment/getEnvironment.d.ts.map +0 -10
  248. package/lib/esm/environment/getEnvironment.js.map +0 -10
  249. package/lib/esm/environment/npmConfig.d.ts.map +0 -10
  250. package/lib/esm/environment/npmConfig.js.map +0 -10
  251. package/lib/esm/environment/pathEnvironment.d.ts.map +0 -10
  252. package/lib/esm/environment/pathEnvironment.js.map +0 -10
  253. package/lib/esm/error/linux.d.ts.map +0 -10
  254. package/lib/esm/error/linux.js.map +0 -10
  255. package/lib/esm/error/nodejs-error-code.generated.d.ts +0 -2485
  256. package/lib/esm/error/nodejs-error-code.generated.d.ts.map +0 -10
  257. package/lib/esm/error/nodejs-error-code.generated.js +0 -2495
  258. package/lib/esm/error/nodejs-error-code.generated.js.map +0 -10
  259. package/lib/esm/error/types.d.ts.map +0 -10
  260. package/lib/esm/error/types.js.map +0 -10
  261. package/lib/esm/events/dumpEventEmitter.d.ts.map +0 -10
  262. package/lib/esm/events/dumpEventEmitter.js.map +0 -10
  263. package/lib/esm/fs/commandExists.d.ts.map +0 -10
  264. package/lib/esm/fs/commandExists.js.map +0 -10
  265. package/lib/esm/fs/emptyDir.d.ts +0 -7
  266. package/lib/esm/fs/emptyDir.d.ts.map +0 -10
  267. package/lib/esm/fs/emptyDir.js.map +0 -10
  268. package/lib/esm/fs/exists.d.ts.map +0 -10
  269. package/lib/esm/fs/exists.js.map +0 -10
  270. package/lib/esm/fs/tempFolder.d.ts.map +0 -10
  271. package/lib/esm/fs/tempFolder.js.map +0 -10
  272. package/lib/esm/fs/weiteChanged.d.ts.map +0 -10
  273. package/lib/esm/fs/weiteChanged.js.map +0 -10
  274. package/lib/esm/log/terminal.d.ts.map +0 -10
  275. package/lib/esm/log/terminal.js.map +0 -10
  276. package/lib/esm/path-resolve/findPackageRoot.d.ts.map +0 -10
  277. package/lib/esm/path-resolve/findPackageRoot.js.map +0 -10
  278. package/lib/esm/path-resolve/findUp.d.ts.map +0 -10
  279. package/lib/esm/path-resolve/findUp.js +0 -68
  280. package/lib/esm/path-resolve/findUp.js.map +0 -10
  281. package/lib/esm/path-resolve/getAllUp.d.ts.map +0 -10
  282. package/lib/esm/path-resolve/getAllUp.js.map +0 -10
  283. package/lib/esm/path-resolve/lrelative.d.ts.map +0 -10
  284. package/lib/esm/path-resolve/lrelative.js.map +0 -10
  285. package/lib/esm/path-resolve/nodeResolvePathArray.d.ts.map +0 -10
  286. package/lib/esm/path-resolve/nodeResolvePathArray.js.map +0 -10
  287. package/lib/esm/path-resolve/resolvePath.d.ts.map +0 -10
  288. package/lib/esm/path-resolve/resolvePath.js.map +0 -10
  289. package/lib/esm/preload.d.ts.map +0 -10
  290. package/lib/esm/preload.js +0 -2
  291. package/lib/esm/preload.js.map +0 -10
  292. package/lib/esm/stream/blackHoleStream.d.ts.map +0 -10
  293. package/lib/esm/stream/blackHoleStream.js.map +0 -10
  294. package/lib/esm/stream/collectingStream.d.ts.map +0 -10
  295. package/lib/esm/stream/collectingStream.js.map +0 -10
  296. package/lib/esm/stream/disposableStream.d.ts.map +0 -10
  297. package/lib/esm/stream/disposableStream.js.map +0 -10
  298. package/lib/esm/stream/drainStream.d.ts.map +0 -10
  299. package/lib/esm/stream/drainStream.js.map +0 -10
  300. package/lib/esm/stream/loggerStream.d.ts.map +0 -10
  301. package/lib/esm/stream/loggerStream.js.map +0 -10
  302. package/lib/esm/stream/streamPromise.d.ts.map +0 -10
  303. package/lib/esm/stream/streamPromise.js.map +0 -10
  304. package/src/error/cache.generated.json +0 -3971
  305. package/src/error/nodejs-error-code.generated.ts +0 -2495
  306. package/src/error/nodejs-error-code.generator.ts +0 -67
  307. /package/lib/{esm/child_process → child_process}/error.d.ts +0 -0
  308. /package/lib/{esm/child_process → child_process}/lateError.d.ts +0 -0
  309. /package/lib/{esm/cli-io → cli-io}/output.d.ts +0 -0
  310. /package/lib/{esm/crypto → crypto}/md5.d.ts +0 -0
  311. /package/lib/{esm/crypto → crypto}/sha256.d.ts +0 -0
  312. /package/lib/{esm/environment → environment}/getEnvironment.d.ts +0 -0
  313. /package/lib/{esm/environment → environment}/npmConfig.d.ts +0 -0
  314. /package/lib/{esm/error → error}/linux.d.ts +0 -0
  315. /package/lib/{esm/events → events}/dumpEventEmitter.d.ts +0 -0
  316. /package/lib/{esm/fs → fs}/commandExists.d.ts +0 -0
  317. /package/lib/{esm/fs → fs}/exists.d.ts +0 -0
  318. /package/lib/{esm/fs → fs}/tempFolder.d.ts +0 -0
  319. /package/lib/{esm/fs → fs}/weiteChanged.d.ts +0 -0
  320. /package/lib/{esm/log → log}/terminal.d.ts +0 -0
  321. /package/lib/{esm/path-resolve → path-resolve}/findPackageRoot.d.ts +0 -0
  322. /package/lib/{esm/path-resolve → path-resolve}/getAllUp.d.ts +0 -0
  323. /package/lib/{esm/path-resolve → path-resolve}/lrelative.d.ts +0 -0
  324. /package/lib/{esm/path-resolve → path-resolve}/nodeResolvePathArray.d.ts +0 -0
  325. /package/lib/{esm/path-resolve → path-resolve}/resolvePath.d.ts +0 -0
  326. /package/lib/{esm/preload.d.ts → preload.d.ts} +0 -0
  327. /package/lib/{esm/stream → stream}/blackHoleStream.d.ts +0 -0
  328. /package/lib/{esm/stream → stream}/collectingStream.d.ts +0 -0
  329. /package/lib/{esm/stream → stream}/disposableStream.d.ts +0 -0
  330. /package/lib/{esm/stream → stream}/drainStream.d.ts +0 -0
  331. /package/lib/{esm/stream → stream}/loggerStream.d.ts +0 -0
  332. /package/lib/{esm/stream → stream}/streamPromise.d.ts +0 -0
package/package.json CHANGED
@@ -1,49 +1,35 @@
1
1
  {
2
2
  "name": "@idlebox/node",
3
3
  "type": "module",
4
- "version": "1.4.6",
5
- "license": "MIT",
6
- "main": "./lib/cjs/__create_index.generated.cjs",
7
- "module": "./lib/esm/__create_index.generated.js",
8
- "types": "./lib/esm/__create_index.generated.d.ts",
4
+ "version": "1.4.7",
9
5
  "exports": {
10
6
  ".": {
11
- "types": "./lib/esm/__create_index.generated.d.ts",
12
- "require": "./lib/cjs/__create_index.generated.cjs",
13
- "import": "./lib/esm/__create_index.generated.js"
7
+ "source": "./src/autoindex.generated.ts",
8
+ "types": "./src/autoindex.generated.ts",
9
+ "default": "./lib/autoindex.generated.js"
14
10
  },
15
11
  "./package.json": "./package.json"
16
12
  },
17
13
  "sideEffects": false,
18
- "repository": "https://github.com/GongT/baobao",
19
14
  "dependencies": {
20
- "execa": "^9.4.0",
15
+ "execa": "^9.6.0",
21
16
  "source-map-support": "^0.5.21",
22
- "@gongt/fix-esm": "^1.1.4",
23
- "@idlebox/common": "^1.4.11"
17
+ "@idlebox/node-error-codes": "",
18
+ "@idlebox/common": "^1.4.14"
24
19
  },
25
20
  "devDependencies": {
26
- "@rushstack/heft": "^0.68.2",
27
- "@types/node": "^22.14.1",
28
- "@internal/local-rig": "^1.0.1",
29
- "@build-script/single-dog-asset": "^1.0.34"
30
- },
31
- "peerDependencies": {
32
- "fix-esm": "^1.0.1"
33
- },
34
- "peerDependenciesMeta": {
35
- "fix-esm": {
36
- "optional": true
37
- }
38
- },
39
- "optionalDependencies": {
40
- "kexec": "npm:@gongt/kexec@latest"
21
+ "@rushstack/heft": "^0.74.0",
22
+ "@types/node": "^24.0.14",
23
+ "@build-script/single-dog-asset": "^1.0.35",
24
+ "@mpis/run": "^0.0.2",
25
+ "@internal/local-rig": "^1.0.1"
41
26
  },
27
+ "decoupledDependents": "*",
42
28
  "scripts": {
43
- "test": "heft test",
44
- "build": "heft --unmanaged build",
45
- "_phase:build": "heft --unmanaged build",
46
- "watch": "heft --unmanaged build-watch",
47
- "clean": "heft clean"
29
+ "prepublishHook": "internal-prepublish-hook",
30
+ "build": "mpis-run build",
31
+ "watch": "mpis-run watch",
32
+ "clean": "mpis-run clean",
33
+ "lint": "internal-lint"
48
34
  }
49
35
  }
package/src/asyncLoad.ts CHANGED
@@ -1,16 +1,7 @@
1
- import { prettyPrintError } from '@idlebox/common';
1
+ import { AppExit, prettyPrintError } from '@idlebox/common';
2
2
 
3
3
  export type AsyncMainFunction = () => Promise<undefined | number> | Promise<void>;
4
4
 
5
- export class ExitError extends Error {
6
- constructor(
7
- message: string,
8
- public readonly code: number = 1
9
- ) {
10
- super(message);
11
- }
12
- }
13
-
14
5
  type OnExit = (error?: Error) => Promise<any>;
15
6
 
16
7
  /**
@@ -19,7 +10,7 @@ type OnExit = (error?: Error) => Promise<any>;
19
10
  * setErrorLogRoot(require('path').dirname(__dirname));
20
11
  * ```
21
12
  **/
22
- export function runMain(main: AsyncMainFunction, onExit?: OnExit) {
13
+ export function executeMainFunction(main: AsyncMainFunction, onExit?: OnExit) {
23
14
  Promise.resolve()
24
15
  .then(async () => {
25
16
  try {
@@ -34,7 +25,7 @@ export function runMain(main: AsyncMainFunction, onExit?: OnExit) {
34
25
  }
35
26
  })
36
27
  .catch((e) => {
37
- if (e instanceof ExitError) {
28
+ if (e instanceof AppExit) {
38
29
  if (e.code) {
39
30
  console.error('[exit] %s', e.message);
40
31
  process.exitCode = e.code;
@@ -0,0 +1,159 @@
1
+ // DO NOT EDIT THIS FILE
2
+ // @ts-ignore
3
+ /* eslint-disable */
4
+
5
+ /* asyncLoad.ts */
6
+ // Identifiers
7
+ export type { AsyncMainFunction } from "./asyncLoad.js";
8
+ export { executeMainFunction } from "./asyncLoad.js";
9
+ /* child_process/error.ts */
10
+ // Identifiers
11
+ export { checkChildProcessResult } from "./child_process/error.js";
12
+ /* child_process/execa.ts */
13
+ // Identifiers
14
+ export type { ICommand } from "./child_process/execa.js";
15
+ export { spawnWithoutOutputSync } from "./child_process/execa.js";
16
+ export { spawnWithoutOutput } from "./child_process/execa.js";
17
+ export { spawnGetOutputSync } from "./child_process/execa.js";
18
+ export { spawnGetOutput } from "./child_process/execa.js";
19
+ export { spawnGetEverything } from "./child_process/execa.js";
20
+ /* cli-io/output.ts */
21
+ // Identifiers
22
+ export { printLine } from "./cli-io/output.js";
23
+ /* child_process/lateError.ts */
24
+ // Identifiers
25
+ export type { ISpawnOptions } from "./child_process/lateError.js";
26
+ export type { ExecaReturnValue } from "./child_process/lateError.js";
27
+ export { execLazyError } from "./child_process/lateError.js";
28
+ /* error/linux.ts */
29
+ // Identifiers
30
+ export { LinuxError } from "./error/linux.js";
31
+ /* error/types.ts */
32
+ // Identifiers
33
+ export type { OpenSSLException } from "./error/types.js";
34
+ export { isModuleResolutionError } from "./error/types.js";
35
+ export { isNotExistsError } from "./error/types.js";
36
+ export { isExistsError } from "./error/types.js";
37
+ export { isTypeError } from "./error/types.js";
38
+ export { isFileTypeError } from "./error/types.js";
39
+ export { isNodeError } from "./error/types.js";
40
+ // References
41
+ export * from "@idlebox/node-error-codes";
42
+ /* fs/exists.ts */
43
+ // Identifiers
44
+ export { existsSync } from "./fs/exists.js";
45
+ export { exists } from "./fs/exists.js";
46
+ export { readFileIfExists } from "./fs/exists.js";
47
+ /* environment/getEnvironment.ts */
48
+ // Identifiers
49
+ export type { IEnvironmentResult } from "./environment/getEnvironment.js";
50
+ export { getEnvironment } from "./environment/getEnvironment.js";
51
+ export { deleteEnvironment } from "./environment/getEnvironment.js";
52
+ export { cleanupEnvironment } from "./environment/getEnvironment.js";
53
+ /* environment/pathEnvironment.ts */
54
+ // Identifiers
55
+ export { PATH_SEPARATOR } from "./environment/pathEnvironment.js";
56
+ export { PathEnvironment } from "./environment/pathEnvironment.js";
57
+ /* environment/findBinary.ts */
58
+ // Identifiers
59
+ export { findBinary } from "./environment/findBinary.js";
60
+ /* child_process/respawn.ts */
61
+ // Identifiers
62
+ export { spawnRecreateEventHandlers } from "./child_process/respawn.js";
63
+ export { trySpawnInScope } from "./child_process/respawn.js";
64
+ export { respawnInScope } from "./child_process/respawn.js";
65
+ /* crypto/md5.ts */
66
+ // Identifiers
67
+ export { md5 } from "./crypto/md5.js";
68
+ /* crypto/sha256.ts */
69
+ // Identifiers
70
+ export { sha256 } from "./crypto/sha256.js";
71
+ /* environment/npmConfig.ts */
72
+ // Identifiers
73
+ export { getNpmConfigValue } from "./environment/npmConfig.js";
74
+ /* events/dumpEventEmitter.ts */
75
+ // Identifiers
76
+ export { dumpEventEmitterEmit } from "./events/dumpEventEmitter.js";
77
+ /* fs/commandExists.ts */
78
+ // Identifiers
79
+ export { commandInPath } from "./fs/commandExists.js";
80
+ export { commandInPathSync } from "./fs/commandExists.js";
81
+ /* fs/emptyDir.ts */
82
+ // Identifiers
83
+ export { emptyDir } from "./fs/emptyDir.js";
84
+ /* fs/ensureDir.ts */
85
+ // Identifiers
86
+ export { ensureDirExists } from "./fs/ensureDir.js";
87
+ export { ensureParentExists } from "./fs/ensureDir.js";
88
+ /* fs/tempFolder.ts */
89
+ // Identifiers
90
+ export { createTempFolder } from "./fs/tempFolder.js";
91
+ /* fs/weiteChanged.ts */
92
+ // Identifiers
93
+ export { writeFileIfChangeSync } from "./fs/weiteChanged.js";
94
+ export { writeFileIfChange } from "./fs/weiteChanged.js";
95
+ /* lifecycle/register.ts */
96
+ // Identifiers
97
+ export { shutdown } from "./lifecycle/register.js";
98
+ export { registerNodejsExitHandler } from "./lifecycle/register.js";
99
+ export { die } from "./lifecycle/register.js";
100
+ /* log/terminal.ts */
101
+ // Identifiers
102
+ export { WrappedTerminalConsole } from "./log/terminal.js";
103
+ /* path-resolve/findUp.ts */
104
+ // Identifiers
105
+ export type { IFindOptions } from "./path-resolve/findUp.js";
106
+ export { findUpUntil } from "./path-resolve/findUp.js";
107
+ export { findUp } from "./path-resolve/findUp.js";
108
+ export { findUpUntilSync } from "./path-resolve/findUp.js";
109
+ export { findUpSync } from "./path-resolve/findUp.js";
110
+ /* path-resolve/findPackageRoot.ts */
111
+ // Identifiers
112
+ export { findPackageRoot } from "./path-resolve/findPackageRoot.js";
113
+ /* path-resolve/getAllUp.ts */
114
+ // Identifiers
115
+ export { getAllPathUpToRoot } from "./path-resolve/getAllUp.js";
116
+ /* path-resolve/lrelative.ts */
117
+ // Identifiers
118
+ export { lrelative } from "./path-resolve/lrelative.js";
119
+ /* path-resolve/nodeResolvePathArray.ts */
120
+ // Identifiers
121
+ export { nodeResolvePathArray } from "./path-resolve/nodeResolvePathArray.js";
122
+ /* path-resolve/resolvePath.ts */
123
+ // Identifiers
124
+ export type { ResolvePathFunction } from "./path-resolve/resolvePath.js";
125
+ export type { JoinPathFunction } from "./path-resolve/resolvePath.js";
126
+ export { resolvePath } from "./path-resolve/resolvePath.js";
127
+ export type { NormalizePathFunction } from "./path-resolve/resolvePath.js";
128
+ export { normalizePath } from "./path-resolve/resolvePath.js";
129
+ export { osTempDir } from "./path-resolve/resolvePath.js";
130
+ export { relativePath } from "./path-resolve/resolvePath.js";
131
+ /* stream/blackHoleStream.ts */
132
+ // Identifiers
133
+ export { BlackHoleStream } from "./stream/blackHoleStream.js";
134
+ /* stream/streamPromise.ts */
135
+ // Identifiers
136
+ export { streamPromise } from "./stream/streamPromise.js";
137
+ export { streamHasEnd } from "./stream/streamPromise.js";
138
+ /* stream/collectingStream.ts */
139
+ // Identifiers
140
+ export { streamToBuffer } from "./stream/collectingStream.js";
141
+ export { RawCollectingStream } from "./stream/collectingStream.js";
142
+ export { CollectingStream } from "./stream/collectingStream.js";
143
+ /* stream/disposableStream.ts */
144
+ // Identifiers
145
+ export { disposableStream } from "./stream/disposableStream.js";
146
+ /* stream/drainStream.ts */
147
+ // Identifiers
148
+ export { drainStream } from "./stream/drainStream.js";
149
+ /* stream/loggerStream.ts */
150
+ // Identifiers
151
+ export type { LogFunction } from "./stream/loggerStream.js";
152
+ export { LoggerStream } from "./stream/loggerStream.js";
153
+ export { HexDumpLoggerStream } from "./stream/loggerStream.js";
154
+ /* autoindex.ts */
155
+ // Identifiers
156
+ // References
157
+ export * from "@idlebox/node-error-codes";
158
+ /* preload.ts */
159
+ // Identifiers
@@ -0,0 +1,153 @@
1
+ // DO NOT EDIT THIS FILE
2
+ // @ts-ignore
3
+ /* eslint-disable */
4
+
5
+ /* asyncLoad.ts */
6
+ // Identifiers
7
+ export type { AsyncMainFunction } from "./asyncLoad.js";
8
+ export { executeMainFunction } from "./asyncLoad.js";
9
+ /* preload.ts */
10
+ // Identifiers
11
+ /* child_process/error.ts */
12
+ // Identifiers
13
+ export { checkChildProcessResult } from "./child_process/error.js";
14
+ /* child_process/execa.ts */
15
+ // Identifiers
16
+ export type { ICommand } from "./child_process/execa.js";
17
+ export { spawnWithoutOutputSync } from "./child_process/execa.js";
18
+ export { spawnWithoutOutput } from "./child_process/execa.js";
19
+ export { spawnGetOutputSync } from "./child_process/execa.js";
20
+ export { spawnGetOutput } from "./child_process/execa.js";
21
+ export { spawnGetEverything } from "./child_process/execa.js";
22
+ /* cli-io/output.ts */
23
+ // Identifiers
24
+ export { printLine } from "./cli-io/output.js";
25
+ /* child_process/lateError.ts */
26
+ // Identifiers
27
+ export type { ISpawnOptions } from "./child_process/lateError.js";
28
+ export type { ExecaReturnValue } from "./child_process/lateError.js";
29
+ export { execLazyError } from "./child_process/lateError.js";
30
+ /* error/linux.ts */
31
+ // Identifiers
32
+ export { LinuxError } from "./error/linux.js";
33
+ /* error/types.ts */
34
+ // Identifiers
35
+ export type { OpenSSLException } from "./error/types.js";
36
+ export { isModuleResolutionError } from "./error/types.js";
37
+ export { isNotExistsError } from "./error/types.js";
38
+ export { isExistsError } from "./error/types.js";
39
+ export { isTypeError } from "./error/types.js";
40
+ export { isFileTypeError } from "./error/types.js";
41
+ export { isNodeError } from "./error/types.js";
42
+ // References
43
+ export * from "@idlebox/node-error-codes";
44
+ /* fs/exists.ts */
45
+ // Identifiers
46
+ export { existsSync } from "./fs/exists.js";
47
+ export { exists } from "./fs/exists.js";
48
+ export { readFileIfExists } from "./fs/exists.js";
49
+ /* environment/getEnvironment.ts */
50
+ // Identifiers
51
+ export type { IEnvironmentResult } from "./environment/getEnvironment.js";
52
+ export { getEnvironment } from "./environment/getEnvironment.js";
53
+ export { deleteEnvironment } from "./environment/getEnvironment.js";
54
+ export { cleanupEnvironment } from "./environment/getEnvironment.js";
55
+ /* environment/pathEnvironment.ts */
56
+ // Identifiers
57
+ export { PATH_SEPARATOR } from "./environment/pathEnvironment.js";
58
+ export { PathEnvironment } from "./environment/pathEnvironment.js";
59
+ /* environment/findBinary.ts */
60
+ // Identifiers
61
+ export { findBinary } from "./environment/findBinary.js";
62
+ /* child_process/respawn.ts */
63
+ // Identifiers
64
+ export { spawnRecreateEventHandlers } from "./child_process/respawn.js";
65
+ export { trySpawnInScope } from "./child_process/respawn.js";
66
+ export { respawnInScope } from "./child_process/respawn.js";
67
+ /* crypto/md5.ts */
68
+ // Identifiers
69
+ export { md5 } from "./crypto/md5.js";
70
+ /* crypto/sha256.ts */
71
+ // Identifiers
72
+ export { sha256 } from "./crypto/sha256.js";
73
+ /* environment/npmConfig.ts */
74
+ // Identifiers
75
+ export { getNpmConfigValue } from "./environment/npmConfig.js";
76
+ /* events/dumpEventEmitter.ts */
77
+ // Identifiers
78
+ export { dumpEventEmitterEmit } from "./events/dumpEventEmitter.js";
79
+ /* fs/commandExists.ts */
80
+ // Identifiers
81
+ export { commandInPath } from "./fs/commandExists.js";
82
+ export { commandInPathSync } from "./fs/commandExists.js";
83
+ /* fs/emptyDir.ts */
84
+ // Identifiers
85
+ export { emptyDir } from "./fs/emptyDir.js";
86
+ /* fs/ensureDir.ts */
87
+ // Identifiers
88
+ export { ensureDirExists } from "./fs/ensureDir.js";
89
+ export { ensureParentExists } from "./fs/ensureDir.js";
90
+ /* fs/tempFolder.ts */
91
+ // Identifiers
92
+ export { createTempFolder } from "./fs/tempFolder.js";
93
+ /* fs/weiteChanged.ts */
94
+ // Identifiers
95
+ export { writeFileIfChangeSync } from "./fs/weiteChanged.js";
96
+ export { writeFileIfChange } from "./fs/weiteChanged.js";
97
+ /* lifecycle/register.ts */
98
+ // Identifiers
99
+ export { shutdown } from "./lifecycle/register.js";
100
+ export { registerNodejsExitHandler } from "./lifecycle/register.js";
101
+ export { die } from "./lifecycle/register.js";
102
+ /* log/terminal.ts */
103
+ // Identifiers
104
+ export { WrappedTerminalConsole } from "./log/terminal.js";
105
+ /* path-resolve/findUp.ts */
106
+ // Identifiers
107
+ export type { IFindOptions } from "./path-resolve/findUp.js";
108
+ export { findUpUntil } from "./path-resolve/findUp.js";
109
+ export { findUpUntilSync } from "./path-resolve/findUp.js";
110
+ /* path-resolve/findPackageRoot.ts */
111
+ // Identifiers
112
+ export { findPackageRoot } from "./path-resolve/findPackageRoot.js";
113
+ /* path-resolve/getAllUp.ts */
114
+ // Identifiers
115
+ export { getAllPathUpToRoot } from "./path-resolve/getAllUp.js";
116
+ /* path-resolve/lrelative.ts */
117
+ // Identifiers
118
+ export { lrelative } from "./path-resolve/lrelative.js";
119
+ /* path-resolve/nodeResolvePathArray.ts */
120
+ // Identifiers
121
+ export { nodeResolvePathArray } from "./path-resolve/nodeResolvePathArray.js";
122
+ /* path-resolve/resolvePath.ts */
123
+ // Identifiers
124
+ export type { ResolvePathFunction } from "./path-resolve/resolvePath.js";
125
+ export type { JoinPathFunction } from "./path-resolve/resolvePath.js";
126
+ export { resolvePath } from "./path-resolve/resolvePath.js";
127
+ export type { NormalizePathFunction } from "./path-resolve/resolvePath.js";
128
+ export { normalizePath } from "./path-resolve/resolvePath.js";
129
+ export { osTempDir } from "./path-resolve/resolvePath.js";
130
+ export { relativePath } from "./path-resolve/resolvePath.js";
131
+ /* stream/blackHoleStream.ts */
132
+ // Identifiers
133
+ export { BlackHoleStream } from "./stream/blackHoleStream.js";
134
+ /* stream/streamPromise.ts */
135
+ // Identifiers
136
+ export { streamPromise } from "./stream/streamPromise.js";
137
+ export { streamHasEnd } from "./stream/streamPromise.js";
138
+ /* stream/collectingStream.ts */
139
+ // Identifiers
140
+ export { streamToBuffer } from "./stream/collectingStream.js";
141
+ export { RawCollectingStream } from "./stream/collectingStream.js";
142
+ export { CollectingStream } from "./stream/collectingStream.js";
143
+ /* stream/disposableStream.ts */
144
+ // Identifiers
145
+ export { disposableStream } from "./stream/disposableStream.js";
146
+ /* stream/drainStream.ts */
147
+ // Identifiers
148
+ export { drainStream } from "./stream/drainStream.js";
149
+ /* stream/loggerStream.ts */
150
+ // Identifiers
151
+ export type { LogFunction } from "./stream/loggerStream.js";
152
+ export { LoggerStream } from "./stream/loggerStream.js";
153
+ export { HexDumpLoggerStream } from "./stream/loggerStream.js";
@@ -1,4 +1,3 @@
1
- import '@gongt/fix-esm';
2
1
  import { isWindows, sepList } from '@idlebox/common';
3
2
  import type { Options as AsyncOptions, Result as AsyncResult, SyncOptions, SyncResult } from 'execa';
4
3
  import { execa, execaSync } from 'execa';
@@ -94,9 +93,15 @@ export async function spawnGetOutput({ exec, cwd, env, addonPath }: ICommand) {
94
93
  return result.stdout as string;
95
94
  }
96
95
 
97
- export async function spawnGetEverything({ exec, cwd, env, addonPath }: ICommand) {
96
+ type EveryOut = {
97
+ stdout: string;
98
+ stderr: string;
99
+ all: string;
100
+ };
101
+ export async function spawnGetEverything({ exec, cwd, env, addonPath }: ICommand): Promise<EveryOut> {
98
102
  const [cmd, ...args] = exec;
99
- const opts: AsyncOptions = {
103
+
104
+ const result = await execa(cmd, args, {
100
105
  stdio: ['ignore', 'pipe', 'pipe'],
101
106
  cwd,
102
107
  reject: false,
@@ -104,9 +109,11 @@ export async function spawnGetEverything({ exec, cwd, env, addonPath }: ICommand
104
109
  encoding: 'utf8',
105
110
  all: true,
106
111
  env: sanitizeEnv(env, addonPath),
107
- };
108
-
109
- const result = await execa(cmd, args, opts);
112
+ });
110
113
  handleError(result);
111
- return result.all as string;
114
+ return {
115
+ all: result.all,
116
+ stdout: result.stdout,
117
+ stderr: result.stderr,
118
+ };
112
119
  }
@@ -1,5 +1,4 @@
1
1
  import { spawnSync } from 'node:child_process';
2
- import { createRequire } from 'node:module';
3
2
  import { platform } from 'node:os';
4
3
  import { findBinary } from '../environment/findBinary.js';
5
4
  import { spawnGetOutputSync } from './execa.js';
@@ -29,7 +28,7 @@ function shutdown_quit(signal: string, code: number) {
29
28
  * If can't do that (eg. on Windows), spawn as normal, but quit self after it quit.
30
29
  */
31
30
  export function trySpawnInScope(cmds: string[]): never {
32
- if (process.env.NEVER_UNSHARE || insideScope() || !supportScope()) {
31
+ if (process.env.NEVER_UNSHARE || !process.execve || insideScope() || !supportScope()) {
33
32
  spawnSimulate(cmds[0], cmds.slice(1));
34
33
  } else {
35
34
  execLinux(cmds);
@@ -37,7 +36,7 @@ export function trySpawnInScope(cmds: string[]): never {
37
36
  }
38
37
 
39
38
  /**
40
- * Self restart in a pid/cgroup namespace on linux.
39
+ * Self restart in a pid+cgroup+mount namespace on linux.
41
40
  * Your application must inside mainFunc, not before or after it.
42
41
  *
43
42
  * ```typescript
@@ -47,7 +46,7 @@ export function trySpawnInScope(cmds: string[]): never {
47
46
  * });
48
47
  * ```
49
48
  */
50
- export function respawnInScope(mainFunc: Function): unknown | never {
49
+ export function respawnInScope(mainFunc: CallableFunction): unknown | never {
51
50
  if (process.env.NEVER_UNSHARE || insideScope() || !supportScope()) {
52
51
  spawnRecreateEventHandlers();
53
52
  mainFunc();
@@ -107,16 +106,12 @@ function execLinux(cmds: string[]): never {
107
106
 
108
107
  try {
109
108
  process.env.NEVER_UNSHARE = 'true';
110
- const require = createRequire(
111
- // @ts-ignore
112
- import.meta.url
113
- );
114
- const kexec = require('kexec');
115
109
 
116
110
  process.removeAllListeners('SIGINT');
117
111
  process.removeAllListeners('SIGTERM');
118
- kexec(unshare, args);
119
- console.error('[Linux] kexec failed.');
112
+ // biome-ignore lint/style/noNonNullAssertion: 上面判断过了
113
+ process.execve!(unshare, args);
114
+ console.error('[Linux] execve failed.');
120
115
  } catch (err: any) {
121
116
  if (
122
117
  err.code === 'MODULE_NOT_FOUND' ||
@@ -125,7 +120,7 @@ function execLinux(cmds: string[]): never {
125
120
  ) {
126
121
  spawnSimulate(unshare, args);
127
122
  } else {
128
- console.error('[Linux] <%s> kexec failed:', err.code, err);
123
+ console.error('[Linux] <%s> execve failed:', err.code, err);
129
124
  }
130
125
  }
131
126
  process.exit(1);
@@ -1,12 +1,9 @@
1
+ import type { PathArray } from '@idlebox/common';
1
2
  import { resolve } from 'node:path';
2
3
  import { existsSync } from '../fs/exists.js';
3
4
  import { PathEnvironment } from './pathEnvironment.js';
4
5
 
5
- export function findBinary(
6
- what: string,
7
- pathvar: import('@idlebox/common').PathArray = new PathEnvironment(),
8
- cwd = process.cwd()
9
- ) {
6
+ export function findBinary(what: string, pathvar: PathArray = new PathEnvironment(), cwd = process.cwd()) {
10
7
  for (const path of pathvar.values()) {
11
8
  if (existsSync(`${path}/${what}`)) {
12
9
  return resolve(cwd, path, what);
@@ -4,7 +4,7 @@ export interface IEnvironmentResult {
4
4
  }
5
5
 
6
6
  export function getEnvironment(name: string, env = process.env): IEnvironmentResult {
7
- if (env.hasOwnProperty(name)) {
7
+ if (Object.hasOwn(env, name)) {
8
8
  return {
9
9
  value: env[name],
10
10
  name: name,
@@ -35,7 +35,7 @@ export function deleteEnvironment(name: string, env = process.env) {
35
35
  }
36
36
 
37
37
  export function cleanupEnvironment(name: string, env = process.env) {
38
- if (env.hasOwnProperty(name)) {
38
+ if (Object.hasOwn(env, name)) {
39
39
  for (const item of Object.keys(env)) {
40
40
  if (item.toLowerCase() === name && name !== item) {
41
41
  delete env[item];
@@ -1,13 +1,16 @@
1
- import { platform } from 'node:os';
2
- import { PathArray } from '@idlebox/common';
1
+ import { isWindows, PathArray } from '@idlebox/common';
3
2
  import { cleanupEnvironment, getEnvironment } from './getEnvironment.js';
4
3
 
5
- export const PATH_SEPARATOR = platform() === 'win32' ? ';' : ':';
4
+ /**
5
+ * PATH_SEPARATOR is the separator used in the PATH environment variable.
6
+ * It is ';' on Windows and ':' on other platforms.
7
+ */
8
+ export const PATH_SEPARATOR = isWindows ? ';' : ':';
6
9
  export class PathEnvironment extends PathArray {
7
10
  private readonly name: string;
8
11
  private readonly env: NodeJS.ProcessEnv;
9
12
 
10
- constructor(varName = platform() === 'win32' ? 'Path' : 'PATH', env: NodeJS.ProcessEnv = process.env) {
13
+ constructor(varName = isWindows ? 'Path' : 'PATH', env: NodeJS.ProcessEnv = process.env) {
11
14
  const { name, value } = getEnvironment(varName, env);
12
15
  super('', PATH_SEPARATOR);
13
16
 
@@ -1,5 +1,6 @@
1
+ import { NodeError } from '@idlebox/node-error-codes';
1
2
  import { LinuxError } from './linux.js';
2
- import { NodeError } from './nodejs-error-code.generated.js';
3
+ export * from '@idlebox/node-error-codes';
3
4
 
4
5
  type NodeException<T extends string = any> = NodeJS.ErrnoException & { code: T };
5
6
 
@@ -15,7 +16,7 @@ export interface OpenSSLException extends Error {
15
16
  * ERR_MODULE_NOT_FOUND: import() not found
16
17
  */
17
18
  export function isModuleResolutionError(
18
- ex: unknown
19
+ ex: unknown,
19
20
  ): ex is NodeException<NodeError.MODULE_NOT_FOUND | NodeError.ERR_MODULE_NOT_FOUND> {
20
21
  return isNodeError(ex) && (ex.code === NodeError.MODULE_NOT_FOUND || ex.code === NodeError.ERR_MODULE_NOT_FOUND);
21
22
  }
@@ -20,7 +20,7 @@ function exts(alterExt?: string[]) {
20
20
 
21
21
  export async function commandInPath(cmd: string, alterExt?: string[]): Promise<string | undefined> {
22
22
  const pathVar = new PathEnvironment();
23
- for (const item of pathVar.join(cmd)) {
23
+ for (const item of pathVar.joinpath(cmd)) {
24
24
  for (const ext of exts(alterExt)) {
25
25
  const found = await new Promise((resolve) => {
26
26
  access(item + ext, constants.X_OK, (e) => {
@@ -35,7 +35,7 @@ export async function commandInPath(cmd: string, alterExt?: string[]): Promise<s
35
35
  }
36
36
  export function commandInPathSync(cmd: string, alterExt?: string[]): string | undefined {
37
37
  const pathVar = new PathEnvironment();
38
- for (const item of pathVar.join(cmd)) {
38
+ for (const item of pathVar.joinpath(cmd)) {
39
39
  for (const ext of exts(alterExt)) {
40
40
  try {
41
41
  accessSync(item + ext, constants.X_OK);
@@ -5,14 +5,17 @@ import { resolve } from 'node:path';
5
5
  * delete all content in a dir,
6
6
  * and create it if not exists
7
7
  * @public
8
+ *
9
+ * @param path - the path to the directory
10
+ * @param create_not_exists - create the directory if it does not exist, defaults to true
8
11
  */
9
- export async function emptyDir(path: string, create_if_nexists = true) {
10
- let files;
12
+ export async function emptyDir(path: string, create_not_exists = true) {
13
+ let files: string[];
11
14
  try {
12
15
  files = await readdir(path);
13
16
  } catch (e: any) {
14
17
  if (e.code === 'ENOENT') {
15
- if (create_if_nexists) await mkdir(path, { recursive: true });
18
+ if (create_not_exists) await mkdir(path, { recursive: true });
16
19
  return;
17
20
  }
18
21
  throw e;
@@ -0,0 +1,19 @@
1
+ import { mkdir } from 'node:fs/promises';
2
+ import { dirname } from 'node:path';
3
+
4
+ export async function ensureDirExists(dir: string) {
5
+ try {
6
+ await mkdir(dir, { recursive: true });
7
+ } catch (error) {
8
+ console.error(`Error creating directory ${dir}:`, error);
9
+ }
10
+ }
11
+
12
+ export async function ensureParentExists(file: string) {
13
+ const dir = dirname(file);
14
+ try {
15
+ await mkdir(dir, { recursive: true });
16
+ } catch (error) {
17
+ console.error(`Error creating directory ${dir}:`, error);
18
+ }
19
+ }