@kubb/agent 4.28.1 → 4.29.1

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 (290) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/server/chunks/nitro/nitro.mjs +416 -682
  3. package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
  4. package/.output/server/chunks/routes/api/health.get.mjs +4 -6
  5. package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
  6. package/.output/server/index.mjs +4 -6
  7. package/.output/server/index.mjs.map +1 -1
  8. package/.output/server/node_modules/@kubb/fabric-core/dist/{defaultParser-BD_N68Bo.js → defaultParser-C1atU7yU.js} +2 -3
  9. package/.output/server/node_modules/@kubb/fabric-core/dist/{getRelativePath-C4Au07ON.js → getRelativePath-BcieQL5M.js} +1 -2
  10. package/.output/server/node_modules/@kubb/fabric-core/dist/index.js +8 -9
  11. package/.output/server/node_modules/@kubb/fabric-core/dist/{Root-BQX3eHqb.js → onProcessExit-CF200hsz.js} +109 -190
  12. package/.output/server/node_modules/@kubb/fabric-core/dist/parsers/typescript.js +3 -4
  13. package/.output/server/node_modules/@kubb/fabric-core/dist/parsers.js +2 -3
  14. package/.output/server/node_modules/@kubb/fabric-core/dist/plugins.js +58 -298
  15. package/.output/server/node_modules/@kubb/fabric-core/package.json +8 -18
  16. package/.output/server/node_modules/@kubb/react-fabric/dist/{chunk-DbZtQ4qb.js → chunk-Cnw5r_-A.js} +1 -5
  17. package/.output/server/node_modules/@kubb/react-fabric/dist/index.js +39 -41
  18. package/.output/server/node_modules/@kubb/react-fabric/dist/{jsx-runtime-CQFBnRKx.js → jsx-runtime-Dm7PKVbc.js} +6 -24
  19. package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime.js +5 -4
  20. package/.output/server/node_modules/@kubb/react-fabric/dist/plugins.js +3 -3
  21. package/.output/server/node_modules/@kubb/react-fabric/dist/{react--draJ5Pm.js → react-D652OKii.js} +31 -91
  22. package/.output/server/node_modules/@kubb/react-fabric/dist/{reactPlugin-DqJsInTf.js → reactPlugin-BkDkx1cs.js} +410 -1650
  23. package/.output/server/node_modules/@kubb/react-fabric/package.json +8 -11
  24. package/.output/server/node_modules/empathic/access.js +39 -0
  25. package/.output/server/node_modules/empathic/access.mjs +34 -0
  26. package/.output/server/node_modules/empathic/find.js +81 -0
  27. package/.output/server/node_modules/empathic/find.mjs +76 -0
  28. package/.output/server/node_modules/empathic/package.json +49 -0
  29. package/.output/server/node_modules/empathic/package.mjs +52 -0
  30. package/.output/server/node_modules/empathic/resolve.js +31 -0
  31. package/.output/server/node_modules/empathic/resolve.mjs +27 -0
  32. package/.output/server/node_modules/empathic/walk.js +22 -0
  33. package/.output/server/node_modules/empathic/walk.mjs +20 -0
  34. package/.output/server/node_modules/tinyexec/dist/main.js +633 -0
  35. package/.output/server/node_modules/tinyexec/package.json +61 -0
  36. package/.output/server/package.json +6 -44
  37. package/package.json +19 -21
  38. package/.output/server/node_modules/.nitro/path-key@3.1.1/index.js +0 -16
  39. package/.output/server/node_modules/.nitro/path-key@3.1.1/package.json +0 -39
  40. package/.output/server/node_modules/.nitro/path-key@4.0.0/index.js +0 -12
  41. package/.output/server/node_modules/.nitro/path-key@4.0.0/package.json +0 -41
  42. package/.output/server/node_modules/.nitro/path-to-regexp@3.3.0/index.js +0 -421
  43. package/.output/server/node_modules/.nitro/path-to-regexp@3.3.0/package.json +0 -46
  44. package/.output/server/node_modules/@kubb/fabric-core/dist/chunk-BVHe6Par.js +0 -22
  45. package/.output/server/node_modules/@sec-ant/readable-stream/dist/ponyfill/asyncIterator.js +0 -89
  46. package/.output/server/node_modules/@sec-ant/readable-stream/dist/ponyfill/fromAnyIterable.js +0 -34
  47. package/.output/server/node_modules/@sec-ant/readable-stream/dist/ponyfill/index.js +0 -6
  48. package/.output/server/node_modules/@sec-ant/readable-stream/package.json +0 -98
  49. package/.output/server/node_modules/@sindresorhus/merge-streams/index.js +0 -265
  50. package/.output/server/node_modules/@sindresorhus/merge-streams/package.json +0 -49
  51. package/.output/server/node_modules/balanced-match/index.js +0 -62
  52. package/.output/server/node_modules/balanced-match/package.json +0 -48
  53. package/.output/server/node_modules/brace-expansion/index.js +0 -201
  54. package/.output/server/node_modules/brace-expansion/package.json +0 -50
  55. package/.output/server/node_modules/bytes/index.js +0 -159
  56. package/.output/server/node_modules/bytes/package.json +0 -39
  57. package/.output/server/node_modules/concat-map/index.js +0 -13
  58. package/.output/server/node_modules/concat-map/package.json +0 -59
  59. package/.output/server/node_modules/content-disposition/index.js +0 -445
  60. package/.output/server/node_modules/content-disposition/package.json +0 -39
  61. package/.output/server/node_modules/cross-spawn/index.js +0 -39
  62. package/.output/server/node_modules/cross-spawn/lib/enoent.js +0 -59
  63. package/.output/server/node_modules/cross-spawn/lib/parse.js +0 -91
  64. package/.output/server/node_modules/cross-spawn/lib/util/escape.js +0 -47
  65. package/.output/server/node_modules/cross-spawn/lib/util/readShebang.js +0 -23
  66. package/.output/server/node_modules/cross-spawn/lib/util/resolveCommand.js +0 -52
  67. package/.output/server/node_modules/cross-spawn/package.json +0 -73
  68. package/.output/server/node_modules/execa/index.js +0 -28
  69. package/.output/server/node_modules/execa/lib/arguments/command.js +0 -20
  70. package/.output/server/node_modules/execa/lib/arguments/cwd.js +0 -39
  71. package/.output/server/node_modules/execa/lib/arguments/encoding-option.js +0 -50
  72. package/.output/server/node_modules/execa/lib/arguments/escape.js +0 -88
  73. package/.output/server/node_modules/execa/lib/arguments/fd-options.js +0 -108
  74. package/.output/server/node_modules/execa/lib/arguments/file-url.js +0 -25
  75. package/.output/server/node_modules/execa/lib/arguments/options.js +0 -96
  76. package/.output/server/node_modules/execa/lib/arguments/shell.js +0 -11
  77. package/.output/server/node_modules/execa/lib/arguments/specific.js +0 -111
  78. package/.output/server/node_modules/execa/lib/convert/add.js +0 -15
  79. package/.output/server/node_modules/execa/lib/convert/concurrent.js +0 -33
  80. package/.output/server/node_modules/execa/lib/convert/duplex.js +0 -69
  81. package/.output/server/node_modules/execa/lib/convert/iterable.js +0 -34
  82. package/.output/server/node_modules/execa/lib/convert/readable.js +0 -113
  83. package/.output/server/node_modules/execa/lib/convert/shared.js +0 -46
  84. package/.output/server/node_modules/execa/lib/convert/writable.js +0 -90
  85. package/.output/server/node_modules/execa/lib/io/contents.js +0 -116
  86. package/.output/server/node_modules/execa/lib/io/input-sync.js +0 -44
  87. package/.output/server/node_modules/execa/lib/io/iterate.js +0 -110
  88. package/.output/server/node_modules/execa/lib/io/max-buffer.js +0 -89
  89. package/.output/server/node_modules/execa/lib/io/output-async.js +0 -80
  90. package/.output/server/node_modules/execa/lib/io/output-sync.js +0 -135
  91. package/.output/server/node_modules/execa/lib/io/pipeline.js +0 -48
  92. package/.output/server/node_modules/execa/lib/io/strip-newline.js +0 -12
  93. package/.output/server/node_modules/execa/lib/ipc/array.js +0 -4
  94. package/.output/server/node_modules/execa/lib/ipc/buffer-messages.js +0 -47
  95. package/.output/server/node_modules/execa/lib/ipc/forward.js +0 -56
  96. package/.output/server/node_modules/execa/lib/ipc/get-each.js +0 -89
  97. package/.output/server/node_modules/execa/lib/ipc/get-one.js +0 -69
  98. package/.output/server/node_modules/execa/lib/ipc/graceful.js +0 -72
  99. package/.output/server/node_modules/execa/lib/ipc/incoming.js +0 -79
  100. package/.output/server/node_modules/execa/lib/ipc/ipc-input.js +0 -44
  101. package/.output/server/node_modules/execa/lib/ipc/methods.js +0 -49
  102. package/.output/server/node_modules/execa/lib/ipc/outgoing.js +0 -47
  103. package/.output/server/node_modules/execa/lib/ipc/reference.js +0 -44
  104. package/.output/server/node_modules/execa/lib/ipc/send.js +0 -91
  105. package/.output/server/node_modules/execa/lib/ipc/strict.js +0 -113
  106. package/.output/server/node_modules/execa/lib/ipc/validation.js +0 -111
  107. package/.output/server/node_modules/execa/lib/methods/bind.js +0 -23
  108. package/.output/server/node_modules/execa/lib/methods/command.js +0 -43
  109. package/.output/server/node_modules/execa/lib/methods/create.js +0 -65
  110. package/.output/server/node_modules/execa/lib/methods/main-async.js +0 -194
  111. package/.output/server/node_modules/execa/lib/methods/main-sync.js +0 -163
  112. package/.output/server/node_modules/execa/lib/methods/node.js +0 -51
  113. package/.output/server/node_modules/execa/lib/methods/parameters.js +0 -31
  114. package/.output/server/node_modules/execa/lib/methods/promise.js +0 -15
  115. package/.output/server/node_modules/execa/lib/methods/script.js +0 -22
  116. package/.output/server/node_modules/execa/lib/methods/template.js +0 -153
  117. package/.output/server/node_modules/execa/lib/pipe/abort.js +0 -20
  118. package/.output/server/node_modules/execa/lib/pipe/pipe-arguments.js +0 -91
  119. package/.output/server/node_modules/execa/lib/pipe/sequence.js +0 -24
  120. package/.output/server/node_modules/execa/lib/pipe/setup.js +0 -72
  121. package/.output/server/node_modules/execa/lib/pipe/streaming.js +0 -51
  122. package/.output/server/node_modules/execa/lib/pipe/throw.js +0 -58
  123. package/.output/server/node_modules/execa/lib/resolve/all-async.js +0 -46
  124. package/.output/server/node_modules/execa/lib/resolve/all-sync.js +0 -33
  125. package/.output/server/node_modules/execa/lib/resolve/exit-async.js +0 -54
  126. package/.output/server/node_modules/execa/lib/resolve/exit-sync.js +0 -25
  127. package/.output/server/node_modules/execa/lib/resolve/stdio.js +0 -47
  128. package/.output/server/node_modules/execa/lib/resolve/wait-stream.js +0 -96
  129. package/.output/server/node_modules/execa/lib/resolve/wait-subprocess.js +0 -146
  130. package/.output/server/node_modules/execa/lib/return/duration.js +0 -8
  131. package/.output/server/node_modules/execa/lib/return/early-error.js +0 -60
  132. package/.output/server/node_modules/execa/lib/return/final-error.js +0 -40
  133. package/.output/server/node_modules/execa/lib/return/message.js +0 -157
  134. package/.output/server/node_modules/execa/lib/return/reject.js +0 -13
  135. package/.output/server/node_modules/execa/lib/return/result.js +0 -186
  136. package/.output/server/node_modules/execa/lib/stdio/direction.js +0 -76
  137. package/.output/server/node_modules/execa/lib/stdio/duplicate.js +0 -116
  138. package/.output/server/node_modules/execa/lib/stdio/handle-async.js +0 -52
  139. package/.output/server/node_modules/execa/lib/stdio/handle-sync.js +0 -57
  140. package/.output/server/node_modules/execa/lib/stdio/handle.js +0 -214
  141. package/.output/server/node_modules/execa/lib/stdio/input-option.js +0 -50
  142. package/.output/server/node_modules/execa/lib/stdio/native.js +0 -106
  143. package/.output/server/node_modules/execa/lib/stdio/stdio-option.js +0 -60
  144. package/.output/server/node_modules/execa/lib/stdio/type.js +0 -173
  145. package/.output/server/node_modules/execa/lib/terminate/cancel.js +0 -20
  146. package/.output/server/node_modules/execa/lib/terminate/cleanup.js +0 -16
  147. package/.output/server/node_modules/execa/lib/terminate/graceful.js +0 -71
  148. package/.output/server/node_modules/execa/lib/terminate/kill.js +0 -93
  149. package/.output/server/node_modules/execa/lib/terminate/signal.js +0 -70
  150. package/.output/server/node_modules/execa/lib/terminate/timeout.js +0 -21
  151. package/.output/server/node_modules/execa/lib/transform/encoding-transform.js +0 -51
  152. package/.output/server/node_modules/execa/lib/transform/generator.js +0 -107
  153. package/.output/server/node_modules/execa/lib/transform/normalize.js +0 -111
  154. package/.output/server/node_modules/execa/lib/transform/object-mode.js +0 -41
  155. package/.output/server/node_modules/execa/lib/transform/run-async.js +0 -60
  156. package/.output/server/node_modules/execa/lib/transform/run-sync.js +0 -50
  157. package/.output/server/node_modules/execa/lib/transform/split.js +0 -110
  158. package/.output/server/node_modules/execa/lib/transform/validate.js +0 -43
  159. package/.output/server/node_modules/execa/lib/utils/abort-signal.js +0 -8
  160. package/.output/server/node_modules/execa/lib/utils/deferred.js +0 -7
  161. package/.output/server/node_modules/execa/lib/utils/max-listeners.js +0 -14
  162. package/.output/server/node_modules/execa/lib/utils/standard-stream.js +0 -6
  163. package/.output/server/node_modules/execa/lib/utils/uint-array.js +0 -69
  164. package/.output/server/node_modules/execa/lib/verbose/complete.js +0 -24
  165. package/.output/server/node_modules/execa/lib/verbose/custom.js +0 -26
  166. package/.output/server/node_modules/execa/lib/verbose/default.js +0 -54
  167. package/.output/server/node_modules/execa/lib/verbose/error.js +0 -13
  168. package/.output/server/node_modules/execa/lib/verbose/info.js +0 -39
  169. package/.output/server/node_modules/execa/lib/verbose/ipc.js +0 -15
  170. package/.output/server/node_modules/execa/lib/verbose/log.js +0 -54
  171. package/.output/server/node_modules/execa/lib/verbose/output.js +0 -60
  172. package/.output/server/node_modules/execa/lib/verbose/start.js +0 -15
  173. package/.output/server/node_modules/execa/lib/verbose/values.js +0 -33
  174. package/.output/server/node_modules/execa/package.json +0 -105
  175. package/.output/server/node_modules/figures/index.js +0 -292
  176. package/.output/server/node_modules/figures/package.json +0 -49
  177. package/.output/server/node_modules/fs-extra/lib/copy/copy-sync.js +0 -176
  178. package/.output/server/node_modules/fs-extra/lib/copy/copy.js +0 -180
  179. package/.output/server/node_modules/fs-extra/lib/copy/index.js +0 -7
  180. package/.output/server/node_modules/fs-extra/lib/empty/index.js +0 -39
  181. package/.output/server/node_modules/fs-extra/lib/ensure/file.js +0 -66
  182. package/.output/server/node_modules/fs-extra/lib/ensure/index.js +0 -23
  183. package/.output/server/node_modules/fs-extra/lib/ensure/link.js +0 -64
  184. package/.output/server/node_modules/fs-extra/lib/ensure/symlink-paths.js +0 -101
  185. package/.output/server/node_modules/fs-extra/lib/ensure/symlink-type.js +0 -34
  186. package/.output/server/node_modules/fs-extra/lib/ensure/symlink.js +0 -67
  187. package/.output/server/node_modules/fs-extra/lib/fs/index.js +0 -146
  188. package/.output/server/node_modules/fs-extra/lib/index.js +0 -16
  189. package/.output/server/node_modules/fs-extra/lib/json/index.js +0 -16
  190. package/.output/server/node_modules/fs-extra/lib/json/jsonfile.js +0 -11
  191. package/.output/server/node_modules/fs-extra/lib/json/output-json-sync.js +0 -12
  192. package/.output/server/node_modules/fs-extra/lib/json/output-json.js +0 -12
  193. package/.output/server/node_modules/fs-extra/lib/mkdirs/index.js +0 -14
  194. package/.output/server/node_modules/fs-extra/lib/mkdirs/make-dir.js +0 -27
  195. package/.output/server/node_modules/fs-extra/lib/mkdirs/utils.js +0 -21
  196. package/.output/server/node_modules/fs-extra/lib/move/index.js +0 -7
  197. package/.output/server/node_modules/fs-extra/lib/move/move-sync.js +0 -55
  198. package/.output/server/node_modules/fs-extra/lib/move/move.js +0 -59
  199. package/.output/server/node_modules/fs-extra/lib/output-file/index.js +0 -31
  200. package/.output/server/node_modules/fs-extra/lib/path-exists/index.js +0 -12
  201. package/.output/server/node_modules/fs-extra/lib/remove/index.js +0 -17
  202. package/.output/server/node_modules/fs-extra/lib/util/async.js +0 -29
  203. package/.output/server/node_modules/fs-extra/lib/util/stat.js +0 -159
  204. package/.output/server/node_modules/fs-extra/lib/util/utimes.js +0 -36
  205. package/.output/server/node_modules/fs-extra/package.json +0 -71
  206. package/.output/server/node_modules/get-stream/package.json +0 -60
  207. package/.output/server/node_modules/get-stream/source/array-buffer.js +0 -84
  208. package/.output/server/node_modules/get-stream/source/array.js +0 -32
  209. package/.output/server/node_modules/get-stream/source/buffer.js +0 -19
  210. package/.output/server/node_modules/get-stream/source/contents.js +0 -121
  211. package/.output/server/node_modules/get-stream/source/exports.js +0 -5
  212. package/.output/server/node_modules/get-stream/source/index.js +0 -13
  213. package/.output/server/node_modules/get-stream/source/stream.js +0 -65
  214. package/.output/server/node_modules/get-stream/source/string.js +0 -41
  215. package/.output/server/node_modules/get-stream/source/utils.js +0 -11
  216. package/.output/server/node_modules/graceful-fs/clone.js +0 -23
  217. package/.output/server/node_modules/graceful-fs/graceful-fs.js +0 -448
  218. package/.output/server/node_modules/graceful-fs/legacy-streams.js +0 -118
  219. package/.output/server/node_modules/graceful-fs/package.json +0 -53
  220. package/.output/server/node_modules/graceful-fs/polyfills.js +0 -355
  221. package/.output/server/node_modules/human-signals/build/src/core.js +0 -273
  222. package/.output/server/node_modules/human-signals/build/src/main.js +0 -70
  223. package/.output/server/node_modules/human-signals/build/src/realtime.js +0 -16
  224. package/.output/server/node_modules/human-signals/build/src/signals.js +0 -34
  225. package/.output/server/node_modules/human-signals/package.json +0 -66
  226. package/.output/server/node_modules/is-plain-obj/index.js +0 -8
  227. package/.output/server/node_modules/is-plain-obj/package.json +0 -41
  228. package/.output/server/node_modules/is-stream/index.js +0 -37
  229. package/.output/server/node_modules/is-stream/package.json +0 -48
  230. package/.output/server/node_modules/is-unicode-supported/index.js +0 -21
  231. package/.output/server/node_modules/is-unicode-supported/package.json +0 -47
  232. package/.output/server/node_modules/isexe/index.js +0 -57
  233. package/.output/server/node_modules/isexe/mode.js +0 -41
  234. package/.output/server/node_modules/isexe/package.json +0 -31
  235. package/.output/server/node_modules/isexe/windows.js +0 -42
  236. package/.output/server/node_modules/js-runtime/dist/index.js +0 -5
  237. package/.output/server/node_modules/js-runtime/package.json +0 -72
  238. package/.output/server/node_modules/jsonfile/index.js +0 -88
  239. package/.output/server/node_modules/jsonfile/package.json +0 -40
  240. package/.output/server/node_modules/jsonfile/utils.js +0 -14
  241. package/.output/server/node_modules/mime-db/db.json +0 -7088
  242. package/.output/server/node_modules/mime-db/index.js +0 -11
  243. package/.output/server/node_modules/mime-db/package.json +0 -57
  244. package/.output/server/node_modules/mime-types/index.js +0 -188
  245. package/.output/server/node_modules/mime-types/package.json +0 -43
  246. package/.output/server/node_modules/minimatch/minimatch.js +0 -947
  247. package/.output/server/node_modules/minimatch/package.json +0 -33
  248. package/.output/server/node_modules/natural-orderby/dist/main.js +0 -19
  249. package/.output/server/node_modules/natural-orderby/dist/umd/natural-orderby.development.js +0 -420
  250. package/.output/server/node_modules/natural-orderby/dist/umd/natural-orderby.production.min.js +0 -11
  251. package/.output/server/node_modules/natural-orderby/package.json +0 -119
  252. package/.output/server/node_modules/npm-run-path/index.js +0 -55
  253. package/.output/server/node_modules/npm-run-path/package.json +0 -52
  254. package/.output/server/node_modules/parse-ms/index.js +0 -45
  255. package/.output/server/node_modules/parse-ms/package.json +0 -47
  256. package/.output/server/node_modules/path-is-inside/lib/path-is-inside.js +0 -28
  257. package/.output/server/node_modules/path-is-inside/package.json +0 -27
  258. package/.output/server/node_modules/pretty-ms/index.js +0 -149
  259. package/.output/server/node_modules/pretty-ms/package.json +0 -55
  260. package/.output/server/node_modules/range-parser/index.js +0 -158
  261. package/.output/server/node_modules/range-parser/package.json +0 -40
  262. package/.output/server/node_modules/serve-handler/package.json +0 -68
  263. package/.output/server/node_modules/serve-handler/src/directory.js +0 -16
  264. package/.output/server/node_modules/serve-handler/src/error.js +0 -10
  265. package/.output/server/node_modules/serve-handler/src/glob-slash.js +0 -9
  266. package/.output/server/node_modules/serve-handler/src/index.js +0 -769
  267. package/.output/server/node_modules/shebang-command/index.js +0 -19
  268. package/.output/server/node_modules/shebang-command/package.json +0 -34
  269. package/.output/server/node_modules/shebang-regex/index.js +0 -2
  270. package/.output/server/node_modules/shebang-regex/package.json +0 -35
  271. package/.output/server/node_modules/signal-exit/dist/mjs/index.js +0 -275
  272. package/.output/server/node_modules/signal-exit/dist/mjs/package.json +0 -3
  273. package/.output/server/node_modules/signal-exit/dist/mjs/signals.js +0 -39
  274. package/.output/server/node_modules/signal-exit/package.json +0 -106
  275. package/.output/server/node_modules/string-argv/index.js +0 -41
  276. package/.output/server/node_modules/string-argv/package.json +0 -51
  277. package/.output/server/node_modules/strip-final-newline/index.js +0 -26
  278. package/.output/server/node_modules/strip-final-newline/package.json +0 -49
  279. package/.output/server/node_modules/unicorn-magic/default.js +0 -14
  280. package/.output/server/node_modules/unicorn-magic/node.js +0 -49
  281. package/.output/server/node_modules/unicorn-magic/package.json +0 -62
  282. package/.output/server/node_modules/universalify/index.js +0 -24
  283. package/.output/server/node_modules/universalify/package.json +0 -34
  284. package/.output/server/node_modules/which/package.json +0 -43
  285. package/.output/server/node_modules/which/which.js +0 -125
  286. package/.output/server/node_modules/yoctocolors/base.js +0 -94
  287. package/.output/server/node_modules/yoctocolors/index.js +0 -2
  288. package/.output/server/node_modules/yoctocolors/package.json +0 -69
  289. /package/.output/server/node_modules/{.nitro/path-to-regexp@8.3.0 → path-to-regexp}/dist/index.js +0 -0
  290. /package/.output/server/node_modules/{.nitro/path-to-regexp@8.3.0 → path-to-regexp}/package.json +0 -0
@@ -1,186 +0,0 @@
1
- import {getSignalDescription} from '../terminate/signal.js';
2
- import {getDurationMs} from './duration.js';
3
- import {getFinalError} from './final-error.js';
4
- import {createMessages} from './message.js';
5
-
6
- // Object returned on subprocess success
7
- export const makeSuccessResult = ({
8
- command,
9
- escapedCommand,
10
- stdio,
11
- all,
12
- ipcOutput,
13
- options: {cwd},
14
- startTime,
15
- }) => omitUndefinedProperties({
16
- command,
17
- escapedCommand,
18
- cwd,
19
- durationMs: getDurationMs(startTime),
20
- failed: false,
21
- timedOut: false,
22
- isCanceled: false,
23
- isGracefullyCanceled: false,
24
- isTerminated: false,
25
- isMaxBuffer: false,
26
- isForcefullyTerminated: false,
27
- exitCode: 0,
28
- stdout: stdio[1],
29
- stderr: stdio[2],
30
- all,
31
- stdio,
32
- ipcOutput,
33
- pipedFrom: [],
34
- });
35
-
36
- // Object returned on subprocess failure before spawning
37
- export const makeEarlyError = ({
38
- error,
39
- command,
40
- escapedCommand,
41
- fileDescriptors,
42
- options,
43
- startTime,
44
- isSync,
45
- }) => makeError({
46
- error,
47
- command,
48
- escapedCommand,
49
- startTime,
50
- timedOut: false,
51
- isCanceled: false,
52
- isGracefullyCanceled: false,
53
- isMaxBuffer: false,
54
- isForcefullyTerminated: false,
55
- stdio: Array.from({length: fileDescriptors.length}),
56
- ipcOutput: [],
57
- options,
58
- isSync,
59
- });
60
-
61
- // Object returned on subprocess failure
62
- export const makeError = ({
63
- error: originalError,
64
- command,
65
- escapedCommand,
66
- startTime,
67
- timedOut,
68
- isCanceled,
69
- isGracefullyCanceled,
70
- isMaxBuffer,
71
- isForcefullyTerminated,
72
- exitCode: rawExitCode,
73
- signal: rawSignal,
74
- stdio,
75
- all,
76
- ipcOutput,
77
- options: {
78
- timeoutDuration,
79
- timeout = timeoutDuration,
80
- forceKillAfterDelay,
81
- killSignal,
82
- cwd,
83
- maxBuffer,
84
- },
85
- isSync,
86
- }) => {
87
- const {exitCode, signal, signalDescription} = normalizeExitPayload(rawExitCode, rawSignal);
88
- const {originalMessage, shortMessage, message} = createMessages({
89
- stdio,
90
- all,
91
- ipcOutput,
92
- originalError,
93
- signal,
94
- signalDescription,
95
- exitCode,
96
- escapedCommand,
97
- timedOut,
98
- isCanceled,
99
- isGracefullyCanceled,
100
- isMaxBuffer,
101
- isForcefullyTerminated,
102
- forceKillAfterDelay,
103
- killSignal,
104
- maxBuffer,
105
- timeout,
106
- cwd,
107
- });
108
- const error = getFinalError(originalError, message, isSync);
109
- Object.assign(error, getErrorProperties({
110
- error,
111
- command,
112
- escapedCommand,
113
- startTime,
114
- timedOut,
115
- isCanceled,
116
- isGracefullyCanceled,
117
- isMaxBuffer,
118
- isForcefullyTerminated,
119
- exitCode,
120
- signal,
121
- signalDescription,
122
- stdio,
123
- all,
124
- ipcOutput,
125
- cwd,
126
- originalMessage,
127
- shortMessage,
128
- }));
129
- return error;
130
- };
131
-
132
- const getErrorProperties = ({
133
- error,
134
- command,
135
- escapedCommand,
136
- startTime,
137
- timedOut,
138
- isCanceled,
139
- isGracefullyCanceled,
140
- isMaxBuffer,
141
- isForcefullyTerminated,
142
- exitCode,
143
- signal,
144
- signalDescription,
145
- stdio,
146
- all,
147
- ipcOutput,
148
- cwd,
149
- originalMessage,
150
- shortMessage,
151
- }) => omitUndefinedProperties({
152
- shortMessage,
153
- originalMessage,
154
- command,
155
- escapedCommand,
156
- cwd,
157
- durationMs: getDurationMs(startTime),
158
- failed: true,
159
- timedOut,
160
- isCanceled,
161
- isGracefullyCanceled,
162
- isTerminated: signal !== undefined,
163
- isMaxBuffer,
164
- isForcefullyTerminated,
165
- exitCode,
166
- signal,
167
- signalDescription,
168
- code: error.cause?.code,
169
- stdout: stdio[1],
170
- stderr: stdio[2],
171
- all,
172
- stdio,
173
- ipcOutput,
174
- pipedFrom: [],
175
- });
176
-
177
- const omitUndefinedProperties = result => Object.fromEntries(Object.entries(result).filter(([, value]) => value !== undefined));
178
-
179
- // `signal` and `exitCode` emitted on `subprocess.on('exit')` event can be `null`.
180
- // We normalize them to `undefined`
181
- const normalizeExitPayload = (rawExitCode, rawSignal) => {
182
- const exitCode = rawExitCode === null ? undefined : rawExitCode;
183
- const signal = rawSignal === null ? undefined : rawSignal;
184
- const signalDescription = signal === undefined ? undefined : getSignalDescription(rawSignal);
185
- return {exitCode, signal, signalDescription};
186
- };
@@ -1,76 +0,0 @@
1
- import process from 'node:process';
2
- import {
3
- isStream as isNodeStream,
4
- isReadableStream as isNodeReadableStream,
5
- isWritableStream as isNodeWritableStream,
6
- } from 'is-stream';
7
- import {isWritableStream} from './type.js';
8
-
9
- // For `stdio[fdNumber]` beyond stdin/stdout/stderr, we need to guess whether the value passed is intended for inputs or outputs.
10
- // This allows us to know whether to pipe _into_ or _from_ the stream.
11
- // When `stdio[fdNumber]` is a single value, this guess is fairly straightforward.
12
- // However, when it is an array instead, we also need to make sure the different values are not incompatible with each other.
13
- export const getStreamDirection = (stdioItems, fdNumber, optionName) => {
14
- const directions = stdioItems.map(stdioItem => getStdioItemDirection(stdioItem, fdNumber));
15
-
16
- if (directions.includes('input') && directions.includes('output')) {
17
- throw new TypeError(`The \`${optionName}\` option must not be an array of both readable and writable values.`);
18
- }
19
-
20
- return directions.find(Boolean) ?? DEFAULT_DIRECTION;
21
- };
22
-
23
- const getStdioItemDirection = ({type, value}, fdNumber) => KNOWN_DIRECTIONS[fdNumber] ?? guessStreamDirection[type](value);
24
-
25
- // `stdin`/`stdout`/`stderr` have a known direction
26
- const KNOWN_DIRECTIONS = ['input', 'output', 'output'];
27
-
28
- const anyDirection = () => undefined;
29
- const alwaysInput = () => 'input';
30
-
31
- // `string` can only be added through the `input` option, i.e. does not need to be handled here
32
- const guessStreamDirection = {
33
- generator: anyDirection,
34
- asyncGenerator: anyDirection,
35
- fileUrl: anyDirection,
36
- filePath: anyDirection,
37
- iterable: alwaysInput,
38
- asyncIterable: alwaysInput,
39
- uint8Array: alwaysInput,
40
- webStream: value => isWritableStream(value) ? 'output' : 'input',
41
- nodeStream(value) {
42
- if (!isNodeReadableStream(value, {checkOpen: false})) {
43
- return 'output';
44
- }
45
-
46
- return isNodeWritableStream(value, {checkOpen: false}) ? undefined : 'input';
47
- },
48
- webTransform: anyDirection,
49
- duplex: anyDirection,
50
- native(value) {
51
- const standardStreamDirection = getStandardStreamDirection(value);
52
- if (standardStreamDirection !== undefined) {
53
- return standardStreamDirection;
54
- }
55
-
56
- if (isNodeStream(value, {checkOpen: false})) {
57
- return guessStreamDirection.nodeStream(value);
58
- }
59
- },
60
- };
61
-
62
- const getStandardStreamDirection = value => {
63
- if ([0, process.stdin].includes(value)) {
64
- return 'input';
65
- }
66
-
67
- if ([1, 2, process.stdout, process.stderr].includes(value)) {
68
- return 'output';
69
- }
70
- };
71
-
72
- // When ambiguous, we initially keep the direction as `undefined`.
73
- // This allows arrays of `stdio` values to resolve the ambiguity.
74
- // For example, `stdio[3]: DuplexStream` is ambiguous, but `stdio[3]: [DuplexStream, WritableStream]` is not.
75
- // When the ambiguity remains, we default to `output` since it is the most common use case for additional file descriptors.
76
- const DEFAULT_DIRECTION = 'output';
@@ -1,116 +0,0 @@
1
- import {
2
- SPECIAL_DUPLICATE_TYPES_SYNC,
3
- SPECIAL_DUPLICATE_TYPES,
4
- FORBID_DUPLICATE_TYPES,
5
- TYPE_TO_MESSAGE,
6
- } from './type.js';
7
-
8
- // Duplicates in the same file descriptor is most likely an error.
9
- // However, this can be useful with generators.
10
- export const filterDuplicates = stdioItems => stdioItems.filter((stdioItemOne, indexOne) =>
11
- stdioItems.every((stdioItemTwo, indexTwo) => stdioItemOne.value !== stdioItemTwo.value
12
- || indexOne >= indexTwo
13
- || stdioItemOne.type === 'generator'
14
- || stdioItemOne.type === 'asyncGenerator'));
15
-
16
- // Check if two file descriptors are sharing the same target.
17
- // For example `{stdout: {file: './output.txt'}, stderr: {file: './output.txt'}}`.
18
- export const getDuplicateStream = ({stdioItem: {type, value, optionName}, direction, fileDescriptors, isSync}) => {
19
- const otherStdioItems = getOtherStdioItems(fileDescriptors, type);
20
- if (otherStdioItems.length === 0) {
21
- return;
22
- }
23
-
24
- if (isSync) {
25
- validateDuplicateStreamSync({
26
- otherStdioItems,
27
- type,
28
- value,
29
- optionName,
30
- direction,
31
- });
32
- return;
33
- }
34
-
35
- if (SPECIAL_DUPLICATE_TYPES.has(type)) {
36
- return getDuplicateStreamInstance({
37
- otherStdioItems,
38
- type,
39
- value,
40
- optionName,
41
- direction,
42
- });
43
- }
44
-
45
- if (FORBID_DUPLICATE_TYPES.has(type)) {
46
- validateDuplicateTransform({
47
- otherStdioItems,
48
- type,
49
- value,
50
- optionName,
51
- });
52
- }
53
- };
54
-
55
- // Values shared by multiple file descriptors
56
- const getOtherStdioItems = (fileDescriptors, type) => fileDescriptors
57
- .flatMap(({direction, stdioItems}) => stdioItems
58
- .filter(stdioItem => stdioItem.type === type)
59
- .map((stdioItem => ({...stdioItem, direction}))));
60
-
61
- // With `execaSync()`, do not allow setting a file path both in input and output
62
- const validateDuplicateStreamSync = ({otherStdioItems, type, value, optionName, direction}) => {
63
- if (SPECIAL_DUPLICATE_TYPES_SYNC.has(type)) {
64
- getDuplicateStreamInstance({
65
- otherStdioItems,
66
- type,
67
- value,
68
- optionName,
69
- direction,
70
- });
71
- }
72
- };
73
-
74
- // When two file descriptors share the file or stream, we need to re-use the same underlying stream.
75
- // Otherwise, the stream would be closed twice when piping ends.
76
- // This is only an issue with output file descriptors.
77
- // This is not a problem with generator functions since those create a new instance for each file descriptor.
78
- // We also forbid input and output file descriptors sharing the same file or stream, since that does not make sense.
79
- const getDuplicateStreamInstance = ({otherStdioItems, type, value, optionName, direction}) => {
80
- const duplicateStdioItems = otherStdioItems.filter(stdioItem => hasSameValue(stdioItem, value));
81
- if (duplicateStdioItems.length === 0) {
82
- return;
83
- }
84
-
85
- const differentStdioItem = duplicateStdioItems.find(stdioItem => stdioItem.direction !== direction);
86
- throwOnDuplicateStream(differentStdioItem, optionName, type);
87
-
88
- return direction === 'output' ? duplicateStdioItems[0].stream : undefined;
89
- };
90
-
91
- const hasSameValue = ({type, value}, secondValue) => {
92
- if (type === 'filePath') {
93
- return value.file === secondValue.file;
94
- }
95
-
96
- if (type === 'fileUrl') {
97
- return value.href === secondValue.href;
98
- }
99
-
100
- return value === secondValue;
101
- };
102
-
103
- // We do not allow two file descriptors to share the same Duplex or TransformStream.
104
- // This is because those are set directly to `subprocess.std*`.
105
- // For example, this could result in `subprocess.stdout` and `subprocess.stderr` being the same value.
106
- // This means reading from either would get data from both stdout and stderr.
107
- const validateDuplicateTransform = ({otherStdioItems, type, value, optionName}) => {
108
- const duplicateStdioItem = otherStdioItems.find(({value: {transform}}) => transform === value.transform);
109
- throwOnDuplicateStream(duplicateStdioItem, optionName, type);
110
- };
111
-
112
- const throwOnDuplicateStream = (stdioItem, optionName, type) => {
113
- if (stdioItem !== undefined) {
114
- throw new TypeError(`The \`${stdioItem.optionName}\` and \`${optionName}\` options must not target ${TYPE_TO_MESSAGE[type]} that is the same.`);
115
- }
116
- };
@@ -1,52 +0,0 @@
1
- import {createReadStream, createWriteStream} from 'node:fs';
2
- import {Buffer} from 'node:buffer';
3
- import {Readable, Writable, Duplex} from 'node:stream';
4
- import {generatorToStream} from '../transform/generator.js';
5
- import {handleStdio} from './handle.js';
6
- import {TYPE_TO_MESSAGE} from './type.js';
7
-
8
- // Handle `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, before spawning, in async mode
9
- export const handleStdioAsync = (options, verboseInfo) => handleStdio(addPropertiesAsync, options, verboseInfo, false);
10
-
11
- const forbiddenIfAsync = ({type, optionName}) => {
12
- throw new TypeError(`The \`${optionName}\` option cannot be ${TYPE_TO_MESSAGE[type]}.`);
13
- };
14
-
15
- // Create streams used internally for piping when using specific values for the `std*` options, in async mode.
16
- // For example, `stdout: {file}` creates a file stream, which is piped from/to.
17
- const addProperties = {
18
- fileNumber: forbiddenIfAsync,
19
- generator: generatorToStream,
20
- asyncGenerator: generatorToStream,
21
- nodeStream: ({value}) => ({stream: value}),
22
- webTransform({value: {transform, writableObjectMode, readableObjectMode}}) {
23
- const objectMode = writableObjectMode || readableObjectMode;
24
- const stream = Duplex.fromWeb(transform, {objectMode});
25
- return {stream};
26
- },
27
- duplex: ({value: {transform}}) => ({stream: transform}),
28
- native() {},
29
- };
30
-
31
- const addPropertiesAsync = {
32
- input: {
33
- ...addProperties,
34
- fileUrl: ({value}) => ({stream: createReadStream(value)}),
35
- filePath: ({value: {file}}) => ({stream: createReadStream(file)}),
36
- webStream: ({value}) => ({stream: Readable.fromWeb(value)}),
37
- iterable: ({value}) => ({stream: Readable.from(value)}),
38
- asyncIterable: ({value}) => ({stream: Readable.from(value)}),
39
- string: ({value}) => ({stream: Readable.from(value)}),
40
- uint8Array: ({value}) => ({stream: Readable.from(Buffer.from(value))}),
41
- },
42
- output: {
43
- ...addProperties,
44
- fileUrl: ({value}) => ({stream: createWriteStream(value)}),
45
- filePath: ({value: {file, append}}) => ({stream: createWriteStream(file, append ? {flags: 'a'} : {})}),
46
- webStream: ({value}) => ({stream: Writable.fromWeb(value)}),
47
- iterable: forbiddenIfAsync,
48
- asyncIterable: forbiddenIfAsync,
49
- string: forbiddenIfAsync,
50
- uint8Array: forbiddenIfAsync,
51
- },
52
- };
@@ -1,57 +0,0 @@
1
- import {readFileSync} from 'node:fs';
2
- import {bufferToUint8Array} from '../utils/uint-array.js';
3
- import {handleStdio} from './handle.js';
4
- import {TYPE_TO_MESSAGE} from './type.js';
5
-
6
- // Normalize `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, before spawning, in sync mode
7
- export const handleStdioSync = (options, verboseInfo) => handleStdio(addPropertiesSync, options, verboseInfo, true);
8
-
9
- const forbiddenIfSync = ({type, optionName}) => {
10
- throwInvalidSyncValue(optionName, TYPE_TO_MESSAGE[type]);
11
- };
12
-
13
- const forbiddenNativeIfSync = ({optionName, value}) => {
14
- if (value === 'ipc' || value === 'overlapped') {
15
- throwInvalidSyncValue(optionName, `"${value}"`);
16
- }
17
-
18
- return {};
19
- };
20
-
21
- const throwInvalidSyncValue = (optionName, value) => {
22
- throw new TypeError(`The \`${optionName}\` option cannot be ${value} with synchronous methods.`);
23
- };
24
-
25
- // Create streams used internally for redirecting when using specific values for the `std*` options, in sync mode.
26
- // For example, `stdin: {file}` reads the file synchronously, then passes it as the `input` option.
27
- const addProperties = {
28
- generator() {},
29
- asyncGenerator: forbiddenIfSync,
30
- webStream: forbiddenIfSync,
31
- nodeStream: forbiddenIfSync,
32
- webTransform: forbiddenIfSync,
33
- duplex: forbiddenIfSync,
34
- asyncIterable: forbiddenIfSync,
35
- native: forbiddenNativeIfSync,
36
- };
37
-
38
- const addPropertiesSync = {
39
- input: {
40
- ...addProperties,
41
- fileUrl: ({value}) => ({contents: [bufferToUint8Array(readFileSync(value))]}),
42
- filePath: ({value: {file}}) => ({contents: [bufferToUint8Array(readFileSync(file))]}),
43
- fileNumber: forbiddenIfSync,
44
- iterable: ({value}) => ({contents: [...value]}),
45
- string: ({value}) => ({contents: [value]}),
46
- uint8Array: ({value}) => ({contents: [value]}),
47
- },
48
- output: {
49
- ...addProperties,
50
- fileUrl: ({value}) => ({path: value}),
51
- filePath: ({value: {file, append}}) => ({path: file, append}),
52
- fileNumber: ({value}) => ({path: value}),
53
- iterable: forbiddenIfSync,
54
- string: forbiddenIfSync,
55
- uint8Array: forbiddenIfSync,
56
- },
57
- };
@@ -1,214 +0,0 @@
1
- import {getStreamName, isStandardStream} from '../utils/standard-stream.js';
2
- import {normalizeTransforms} from '../transform/normalize.js';
3
- import {getFdObjectMode} from '../transform/object-mode.js';
4
- import {
5
- getStdioItemType,
6
- isRegularUrl,
7
- isUnknownStdioString,
8
- FILE_TYPES,
9
- } from './type.js';
10
- import {getStreamDirection} from './direction.js';
11
- import {normalizeStdioOption} from './stdio-option.js';
12
- import {handleNativeStream} from './native.js';
13
- import {handleInputOptions} from './input-option.js';
14
- import {filterDuplicates, getDuplicateStream} from './duplicate.js';
15
-
16
- // Handle `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, before spawning, in async/sync mode
17
- // They are converted into an array of `fileDescriptors`.
18
- // Each `fileDescriptor` is normalized, validated and contains all information necessary for further handling.
19
- export const handleStdio = (addProperties, options, verboseInfo, isSync) => {
20
- const stdio = normalizeStdioOption(options, verboseInfo, isSync);
21
- const initialFileDescriptors = stdio.map((stdioOption, fdNumber) => getFileDescriptor({
22
- stdioOption,
23
- fdNumber,
24
- options,
25
- isSync,
26
- }));
27
- const fileDescriptors = getFinalFileDescriptors({
28
- initialFileDescriptors,
29
- addProperties,
30
- options,
31
- isSync,
32
- });
33
- options.stdio = fileDescriptors.map(({stdioItems}) => forwardStdio(stdioItems));
34
- return fileDescriptors;
35
- };
36
-
37
- const getFileDescriptor = ({stdioOption, fdNumber, options, isSync}) => {
38
- const optionName = getStreamName(fdNumber);
39
- const {stdioItems: initialStdioItems, isStdioArray} = initializeStdioItems({
40
- stdioOption,
41
- fdNumber,
42
- options,
43
- optionName,
44
- });
45
- const direction = getStreamDirection(initialStdioItems, fdNumber, optionName);
46
- const stdioItems = initialStdioItems.map(stdioItem => handleNativeStream({
47
- stdioItem,
48
- isStdioArray,
49
- fdNumber,
50
- direction,
51
- isSync,
52
- }));
53
- const normalizedStdioItems = normalizeTransforms(stdioItems, optionName, direction, options);
54
- const objectMode = getFdObjectMode(normalizedStdioItems, direction);
55
- validateFileObjectMode(normalizedStdioItems, objectMode);
56
- return {direction, objectMode, stdioItems: normalizedStdioItems};
57
- };
58
-
59
- // We make sure passing an array with a single item behaves the same as passing that item without an array.
60
- // This is what users would expect.
61
- // For example, `stdout: ['ignore']` behaves the same as `stdout: 'ignore'`.
62
- const initializeStdioItems = ({stdioOption, fdNumber, options, optionName}) => {
63
- const values = Array.isArray(stdioOption) ? stdioOption : [stdioOption];
64
- const initialStdioItems = [
65
- ...values.map(value => initializeStdioItem(value, optionName)),
66
- ...handleInputOptions(options, fdNumber),
67
- ];
68
-
69
- const stdioItems = filterDuplicates(initialStdioItems);
70
- const isStdioArray = stdioItems.length > 1;
71
- validateStdioArray(stdioItems, isStdioArray, optionName);
72
- validateStreams(stdioItems);
73
- return {stdioItems, isStdioArray};
74
- };
75
-
76
- const initializeStdioItem = (value, optionName) => ({
77
- type: getStdioItemType(value, optionName),
78
- value,
79
- optionName,
80
- });
81
-
82
- const validateStdioArray = (stdioItems, isStdioArray, optionName) => {
83
- if (stdioItems.length === 0) {
84
- throw new TypeError(`The \`${optionName}\` option must not be an empty array.`);
85
- }
86
-
87
- if (!isStdioArray) {
88
- return;
89
- }
90
-
91
- for (const {value, optionName} of stdioItems) {
92
- if (INVALID_STDIO_ARRAY_OPTIONS.has(value)) {
93
- throw new Error(`The \`${optionName}\` option must not include \`${value}\`.`);
94
- }
95
- }
96
- };
97
-
98
- // Using those `stdio` values together with others for the same stream does not make sense, so we make it fail.
99
- // However, we do allow it if the array has a single item.
100
- const INVALID_STDIO_ARRAY_OPTIONS = new Set(['ignore', 'ipc']);
101
-
102
- const validateStreams = stdioItems => {
103
- for (const stdioItem of stdioItems) {
104
- validateFileStdio(stdioItem);
105
- }
106
- };
107
-
108
- const validateFileStdio = ({type, value, optionName}) => {
109
- if (isRegularUrl(value)) {
110
- throw new TypeError(`The \`${optionName}: URL\` option must use the \`file:\` scheme.
111
- For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);
112
- }
113
-
114
- if (isUnknownStdioString(type, value)) {
115
- throw new TypeError(`The \`${optionName}: { file: '...' }\` option must be used instead of \`${optionName}: '...'\`.`);
116
- }
117
- };
118
-
119
- const validateFileObjectMode = (stdioItems, objectMode) => {
120
- if (!objectMode) {
121
- return;
122
- }
123
-
124
- const fileStdioItem = stdioItems.find(({type}) => FILE_TYPES.has(type));
125
- if (fileStdioItem !== undefined) {
126
- throw new TypeError(`The \`${fileStdioItem.optionName}\` option cannot use both files and transforms in objectMode.`);
127
- }
128
- };
129
-
130
- // Some `stdio` values require Execa to create streams.
131
- // For example, file paths create file read/write streams.
132
- // Those transformations are specified in `addProperties`, which is both direction-specific and type-specific.
133
- const getFinalFileDescriptors = ({initialFileDescriptors, addProperties, options, isSync}) => {
134
- const fileDescriptors = [];
135
-
136
- try {
137
- for (const fileDescriptor of initialFileDescriptors) {
138
- fileDescriptors.push(getFinalFileDescriptor({
139
- fileDescriptor,
140
- fileDescriptors,
141
- addProperties,
142
- options,
143
- isSync,
144
- }));
145
- }
146
-
147
- return fileDescriptors;
148
- } catch (error) {
149
- cleanupCustomStreams(fileDescriptors);
150
- throw error;
151
- }
152
- };
153
-
154
- const getFinalFileDescriptor = ({
155
- fileDescriptor: {direction, objectMode, stdioItems},
156
- fileDescriptors,
157
- addProperties,
158
- options,
159
- isSync,
160
- }) => {
161
- const finalStdioItems = stdioItems.map(stdioItem => addStreamProperties({
162
- stdioItem,
163
- addProperties,
164
- direction,
165
- options,
166
- fileDescriptors,
167
- isSync,
168
- }));
169
- return {direction, objectMode, stdioItems: finalStdioItems};
170
- };
171
-
172
- const addStreamProperties = ({stdioItem, addProperties, direction, options, fileDescriptors, isSync}) => {
173
- const duplicateStream = getDuplicateStream({
174
- stdioItem,
175
- direction,
176
- fileDescriptors,
177
- isSync,
178
- });
179
-
180
- if (duplicateStream !== undefined) {
181
- return {...stdioItem, stream: duplicateStream};
182
- }
183
-
184
- return {
185
- ...stdioItem,
186
- ...addProperties[direction][stdioItem.type](stdioItem, options),
187
- };
188
- };
189
-
190
- // The stream error handling is performed by the piping logic above, which cannot be performed before subprocess spawning.
191
- // If the subprocess spawning fails (e.g. due to an invalid command), the streams need to be manually destroyed.
192
- // We need to create those streams before subprocess spawning, in case their creation fails, e.g. when passing an invalid generator as argument.
193
- // Like this, an exception would be thrown, which would prevent spawning a subprocess.
194
- export const cleanupCustomStreams = fileDescriptors => {
195
- for (const {stdioItems} of fileDescriptors) {
196
- for (const {stream} of stdioItems) {
197
- if (stream !== undefined && !isStandardStream(stream)) {
198
- stream.destroy();
199
- }
200
- }
201
- }
202
- };
203
-
204
- // When the `std*: Iterable | WebStream | URL | filePath`, `input` or `inputFile` option is used, we pipe to `subprocess.std*`.
205
- // When the `std*: Array` option is used, we emulate some of the native values ('inherit', Node.js stream and file descriptor integer). To do so, we also need to pipe to `subprocess.std*`.
206
- // Therefore the `std*` options must be either `pipe` or `overlapped`. Other values do not set `subprocess.std*`.
207
- const forwardStdio = stdioItems => {
208
- if (stdioItems.length > 1) {
209
- return stdioItems.some(({value}) => value === 'overlapped') ? 'overlapped' : 'pipe';
210
- }
211
-
212
- const [{type, value}] = stdioItems;
213
- return type === 'native' ? value : 'pipe';
214
- };