@goodbyenjn/utils 26.4.0 → 26.4.2

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.
package/dist/shell.js DELETED
@@ -1,781 +0,0 @@
1
- import { Gt as isString, Tt as isArray, Vt as isPlainObject } from "./chunks/chunk-b61db0a7.js";
2
- import { T as getErrorMessage, a as concatTemplateStrings } from "./chunks/chunk-486f65b0.js";
3
- import { createRequire } from "module";
4
- import { delimiter, dirname, normalize, resolve } from "node:path";
5
- import { spawn } from "node:child_process";
6
- import { cwd } from "node:process";
7
- import { PassThrough } from "node:stream";
8
- import c from "node:readline";
9
-
10
- //#region node_modules/.pnpm/args-tokenizer@0.3.0/node_modules/args-tokenizer/dist/args-tokenizer.js
11
- var spaceRegex = /\s/;
12
- var tokenizeArgs = (argsString, options) => {
13
- const tokens = [];
14
- let currentToken = "";
15
- let openningQuote;
16
- let escaped = false;
17
- for (let index = 0; index < argsString.length; index += 1) {
18
- const char = argsString[index];
19
- if (escaped) {
20
- escaped = false;
21
- if (openningQuote || char !== "\n") currentToken += char;
22
- continue;
23
- }
24
- if (char === "\\") {
25
- escaped = true;
26
- continue;
27
- }
28
- if (openningQuote === void 0 && spaceRegex.test(char)) {
29
- if (currentToken.length > 0) {
30
- tokens.push(currentToken);
31
- currentToken = "";
32
- }
33
- continue;
34
- }
35
- if (char === "'" || char === "\"") {
36
- if (openningQuote === void 0) {
37
- openningQuote = char;
38
- continue;
39
- }
40
- if (openningQuote === char) {
41
- openningQuote = void 0;
42
- continue;
43
- }
44
- }
45
- currentToken += char;
46
- }
47
- if (currentToken.length > 0) tokens.push(currentToken);
48
- if (options?.loose) return tokens;
49
- if (openningQuote) throw Error("Unexpected end of string. Closing quote is missing.");
50
- return tokens;
51
- };
52
-
53
- //#endregion
54
- //#region node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.js
55
- var l = Object.create;
56
- var u = Object.defineProperty;
57
- var d = Object.getOwnPropertyDescriptor;
58
- var f = Object.getOwnPropertyNames;
59
- var p = Object.getPrototypeOf;
60
- var m = Object.prototype.hasOwnProperty;
61
- var h = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
62
- var g = (e, t, n, r) => {
63
- if (t && typeof t === "object" || typeof t === "function") for (var i = f(t), a = 0, o = i.length, s; a < o; a++) {
64
- s = i[a];
65
- if (!m.call(e, s) && s !== n) u(e, s, {
66
- get: ((e) => t[e]).bind(null, s),
67
- enumerable: !(r = d(t, s)) || r.enumerable
68
- });
69
- }
70
- return e;
71
- };
72
- var _ = (e, t, n) => (n = e != null ? l(p(e)) : {}, g(t || !e || !e.__esModule ? u(n, "default", {
73
- value: e,
74
- enumerable: true
75
- }) : n, e));
76
- var v = createRequire(import.meta.url);
77
- const y = /^path$/i;
78
- const b = {
79
- key: "PATH",
80
- value: ""
81
- };
82
- function x(e) {
83
- for (const t in e) {
84
- if (!Object.prototype.hasOwnProperty.call(e, t) || !y.test(t)) continue;
85
- const n = e[t];
86
- if (!n) return b;
87
- return {
88
- key: t,
89
- value: n
90
- };
91
- }
92
- return b;
93
- }
94
- function S(e, t) {
95
- const i = t.value.split(delimiter);
96
- let o = e;
97
- let s;
98
- do {
99
- i.push(resolve(o, "node_modules", ".bin"));
100
- s = o;
101
- o = dirname(o);
102
- } while (o !== s);
103
- return {
104
- key: t.key,
105
- value: i.join(delimiter)
106
- };
107
- }
108
- function C(e, t) {
109
- const n = {
110
- ...process.env,
111
- ...t
112
- };
113
- const r = S(e, x(n));
114
- n[r.key] = r.value;
115
- return n;
116
- }
117
- const w = (e) => {
118
- let t = e.length;
119
- const n = new PassThrough();
120
- const r = () => {
121
- if (--t === 0) n.emit("end");
122
- };
123
- for (const t of e) {
124
- t.pipe(n, { end: false });
125
- t.on("end", r);
126
- }
127
- return n;
128
- };
129
- var T = h((exports, t) => {
130
- t.exports = a;
131
- a.sync = o;
132
- var n = v("fs");
133
- function r(e, t) {
134
- var n = t.pathExt !== void 0 ? t.pathExt : process.env.PATHEXT;
135
- if (!n) return true;
136
- n = n.split(";");
137
- if (n.indexOf("") !== -1) return true;
138
- for (var r = 0; r < n.length; r++) {
139
- var i = n[r].toLowerCase();
140
- if (i && e.substr(-i.length).toLowerCase() === i) return true;
141
- }
142
- return false;
143
- }
144
- function i(e, t, n) {
145
- if (!e.isSymbolicLink() && !e.isFile()) return false;
146
- return r(t, n);
147
- }
148
- function a(e, t, r) {
149
- n.stat(e, function(n, a) {
150
- r(n, n ? false : i(a, e, t));
151
- });
152
- }
153
- function o(e, t) {
154
- return i(n.statSync(e), e, t);
155
- }
156
- });
157
- var E = h((exports, t) => {
158
- t.exports = r;
159
- r.sync = i;
160
- var n = v("fs");
161
- function r(e, t, r) {
162
- n.stat(e, function(e, n) {
163
- r(e, e ? false : a(n, t));
164
- });
165
- }
166
- function i(e, t) {
167
- return a(n.statSync(e), t);
168
- }
169
- function a(e, t) {
170
- return e.isFile() && o(e, t);
171
- }
172
- function o(e, t) {
173
- var n = e.mode;
174
- var r = e.uid;
175
- var i = e.gid;
176
- var a = t.uid !== void 0 ? t.uid : process.getuid && process.getuid();
177
- var o = t.gid !== void 0 ? t.gid : process.getgid && process.getgid();
178
- var s = parseInt("100", 8);
179
- var c = parseInt("010", 8);
180
- var l = parseInt("001", 8);
181
- var u = s | c;
182
- return n & l || n & c && i === o || n & s && r === a || n & u && a === 0;
183
- }
184
- });
185
- var D = h((exports, t) => {
186
- v("fs");
187
- var r;
188
- if (process.platform === "win32" || global.TESTING_WINDOWS) r = T();
189
- else r = E();
190
- t.exports = i;
191
- i.sync = a;
192
- function i(e, t, n) {
193
- if (typeof t === "function") {
194
- n = t;
195
- t = {};
196
- }
197
- if (!n) {
198
- if (typeof Promise !== "function") throw new TypeError("callback not provided");
199
- return new Promise(function(n, r) {
200
- i(e, t || {}, function(e, t) {
201
- if (e) r(e);
202
- else n(t);
203
- });
204
- });
205
- }
206
- r(e, t || {}, function(e, r) {
207
- if (e) {
208
- if (e.code === "EACCES" || t && t.ignoreErrors) {
209
- e = null;
210
- r = false;
211
- }
212
- }
213
- n(e, r);
214
- });
215
- }
216
- function a(e, t) {
217
- try {
218
- return r.sync(e, t || {});
219
- } catch (e) {
220
- if (t && t.ignoreErrors || e.code === "EACCES") return false;
221
- else throw e;
222
- }
223
- }
224
- });
225
- var O = h((exports, t) => {
226
- const n = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
227
- const r = v("path");
228
- const i = n ? ";" : ":";
229
- const a = D();
230
- const o = (e) => Object.assign(new Error(`not found: ${e}`), { code: "ENOENT" });
231
- const s = (e, t) => {
232
- const r = t.colon || i;
233
- const a = e.match(/\//) || n && e.match(/\\/) ? [""] : [...n ? [process.cwd()] : [], ...(t.path || process.env.PATH || "").split(r)];
234
- const o = n ? t.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
235
- const s = n ? o.split(r) : [""];
236
- if (n) {
237
- if (e.indexOf(".") !== -1 && s[0] !== "") s.unshift("");
238
- }
239
- return {
240
- pathEnv: a,
241
- pathExt: s,
242
- pathExtExe: o
243
- };
244
- };
245
- const c = (e, t, n) => {
246
- if (typeof t === "function") {
247
- n = t;
248
- t = {};
249
- }
250
- if (!t) t = {};
251
- const { pathEnv: i, pathExt: c, pathExtExe: l } = s(e, t);
252
- const u = [];
253
- const d = (n) => new Promise((a, s) => {
254
- if (n === i.length) return t.all && u.length ? a(u) : s(o(e));
255
- const c = i[n];
256
- const l = /^".*"$/.test(c) ? c.slice(1, -1) : c;
257
- const d = r.join(l, e);
258
- a(f(!l && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d, n, 0));
259
- });
260
- const f = (e, n, r) => new Promise((i, o) => {
261
- if (r === c.length) return i(d(n + 1));
262
- const s = c[r];
263
- a(e + s, { pathExt: l }, (a, o) => {
264
- if (!a && o) if (t.all) u.push(e + s);
265
- else return i(e + s);
266
- return i(f(e, n, r + 1));
267
- });
268
- });
269
- return n ? d(0).then((e) => n(null, e), n) : d(0);
270
- };
271
- const l = (e, t) => {
272
- t = t || {};
273
- const { pathEnv: n, pathExt: i, pathExtExe: c } = s(e, t);
274
- const l = [];
275
- for (let o = 0; o < n.length; o++) {
276
- const s = n[o];
277
- const u = /^".*"$/.test(s) ? s.slice(1, -1) : s;
278
- const d = r.join(u, e);
279
- const f = !u && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d;
280
- for (let e = 0; e < i.length; e++) {
281
- const n = f + i[e];
282
- try {
283
- if (a.sync(n, { pathExt: c })) if (t.all) l.push(n);
284
- else return n;
285
- } catch (e) {}
286
- }
287
- }
288
- if (t.all && l.length) return l;
289
- if (t.nothrow) return null;
290
- throw o(e);
291
- };
292
- t.exports = c;
293
- c.sync = l;
294
- });
295
- var k = h((exports, t) => {
296
- const n = (e = {}) => {
297
- const t = e.env || process.env;
298
- if ((e.platform || process.platform) !== "win32") return "PATH";
299
- return Object.keys(t).reverse().find((e) => e.toUpperCase() === "PATH") || "Path";
300
- };
301
- t.exports = n;
302
- t.exports.default = n;
303
- });
304
- var A = h((exports, t) => {
305
- const n = v("path");
306
- const r = O();
307
- const i = k();
308
- function a(e, t) {
309
- const a = e.options.env || process.env;
310
- const o = process.cwd();
311
- const s = e.options.cwd != null;
312
- const c = s && process.chdir !== void 0 && !process.chdir.disabled;
313
- if (c) try {
314
- process.chdir(e.options.cwd);
315
- } catch (e) {}
316
- let l;
317
- try {
318
- l = r.sync(e.command, {
319
- path: a[i({ env: a })],
320
- pathExt: t ? n.delimiter : void 0
321
- });
322
- } catch (e) {} finally {
323
- if (c) process.chdir(o);
324
- }
325
- if (l) l = n.resolve(s ? e.options.cwd : "", l);
326
- return l;
327
- }
328
- function o(e) {
329
- return a(e) || a(e, true);
330
- }
331
- t.exports = o;
332
- });
333
- var j = h((exports, t) => {
334
- const n = /([()\][%!^"`<>&|;, *?])/g;
335
- function r(e) {
336
- e = e.replace(n, "^$1");
337
- return e;
338
- }
339
- function i(e, t) {
340
- e = `${e}`;
341
- e = e.replace(/(\\*)"/g, "$1$1\\\"");
342
- e = e.replace(/(\\*)$/, "$1$1");
343
- e = `"${e}"`;
344
- e = e.replace(n, "^$1");
345
- if (t) e = e.replace(n, "^$1");
346
- return e;
347
- }
348
- t.exports.command = r;
349
- t.exports.argument = i;
350
- });
351
- var M = h((exports, t) => {
352
- t.exports = /^#!(.*)/;
353
- });
354
- var N = h((exports, t) => {
355
- const n = M();
356
- t.exports = (e = "") => {
357
- const t = e.match(n);
358
- if (!t) return null;
359
- const [r, i] = t[0].replace(/#! ?/, "").split(" ");
360
- const a = r.split("/").pop();
361
- if (a === "env") return i;
362
- return i ? `${a} ${i}` : a;
363
- };
364
- });
365
- var P = h((exports, t) => {
366
- const n = v("fs");
367
- const r = N();
368
- function i(e) {
369
- const t = 150;
370
- const i = Buffer.alloc(t);
371
- let a;
372
- try {
373
- a = n.openSync(e, "r");
374
- n.readSync(a, i, 0, t, 0);
375
- n.closeSync(a);
376
- } catch (e) {}
377
- return r(i.toString());
378
- }
379
- t.exports = i;
380
- });
381
- var F = h((exports, t) => {
382
- const n = v("path");
383
- const r = A();
384
- const i = j();
385
- const a = P();
386
- const o = process.platform === "win32";
387
- const s = /\.(?:com|exe)$/i;
388
- const c = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
389
- function l(e) {
390
- e.file = r(e);
391
- const t = e.file && a(e.file);
392
- if (t) {
393
- e.args.unshift(e.file);
394
- e.command = t;
395
- return r(e);
396
- }
397
- return e.file;
398
- }
399
- function u(e) {
400
- if (!o) return e;
401
- const t = l(e);
402
- const r = !s.test(t);
403
- if (e.options.forceShell || r) {
404
- const r = c.test(t);
405
- e.command = n.normalize(e.command);
406
- e.command = i.command(e.command);
407
- e.args = e.args.map((e) => i.argument(e, r));
408
- e.args = [
409
- "/d",
410
- "/s",
411
- "/c",
412
- `"${[e.command].concat(e.args).join(" ")}"`
413
- ];
414
- e.command = process.env.comspec || "cmd.exe";
415
- e.options.windowsVerbatimArguments = true;
416
- }
417
- return e;
418
- }
419
- function d(e, t, n) {
420
- if (t && !Array.isArray(t)) {
421
- n = t;
422
- t = null;
423
- }
424
- t = t ? t.slice(0) : [];
425
- n = Object.assign({}, n);
426
- const r = {
427
- command: e,
428
- args: t,
429
- options: n,
430
- file: void 0,
431
- original: {
432
- command: e,
433
- args: t
434
- }
435
- };
436
- return n.shell ? r : u(r);
437
- }
438
- t.exports = d;
439
- });
440
- var I = h((exports, t) => {
441
- const n = process.platform === "win32";
442
- function r(e, t) {
443
- return Object.assign(new Error(`${t} ${e.command} ENOENT`), {
444
- code: "ENOENT",
445
- errno: "ENOENT",
446
- syscall: `${t} ${e.command}`,
447
- path: e.command,
448
- spawnargs: e.args
449
- });
450
- }
451
- function i(e, t) {
452
- if (!n) return;
453
- const r = e.emit;
454
- e.emit = function(n, i) {
455
- if (n === "exit") {
456
- const n = a(i, t, "spawn");
457
- if (n) return r.call(e, "error", n);
458
- }
459
- return r.apply(e, arguments);
460
- };
461
- }
462
- function a(e, t) {
463
- if (n && e === 1 && !t.file) return r(t.original, "spawn");
464
- return null;
465
- }
466
- function o(e, t) {
467
- if (n && e === 1 && !t.file) return r(t.original, "spawnSync");
468
- return null;
469
- }
470
- t.exports = {
471
- hookChildProcess: i,
472
- verifyENOENT: a,
473
- verifyENOENTSync: o,
474
- notFoundError: r
475
- };
476
- });
477
- var R = _(h((exports, t) => {
478
- const n = v("child_process");
479
- const r = F();
480
- const i = I();
481
- function a(e, t, a) {
482
- const o = r(e, t, a);
483
- const s = n.spawn(o.command, o.args, o.options);
484
- i.hookChildProcess(s, o);
485
- return s;
486
- }
487
- function o(e, t, a) {
488
- const o = r(e, t, a);
489
- const s = n.spawnSync(o.command, o.args, o.options);
490
- s.error = s.error || i.verifyENOENTSync(s.status, o);
491
- return s;
492
- }
493
- t.exports = a;
494
- t.exports.spawn = a;
495
- t.exports.sync = o;
496
- t.exports._parse = r;
497
- t.exports._enoent = i;
498
- })(), 1);
499
- var z = class extends Error {
500
- result;
501
- output;
502
- get exitCode() {
503
- if (this.result.exitCode !== null) return this.result.exitCode;
504
- }
505
- constructor(e, t) {
506
- super(`Process exited with non-zero status (${e.exitCode})`);
507
- this.result = e;
508
- this.output = t;
509
- }
510
- };
511
- const B = {
512
- timeout: void 0,
513
- persist: false
514
- };
515
- const V = { windowsHide: true };
516
- function H(e, t) {
517
- return {
518
- command: normalize(e),
519
- args: t ?? []
520
- };
521
- }
522
- function U(e) {
523
- const t = new AbortController();
524
- for (const n of e) {
525
- if (n.aborted) {
526
- t.abort();
527
- return n;
528
- }
529
- const e = () => {
530
- t.abort(n.reason);
531
- };
532
- n.addEventListener("abort", e, { signal: t.signal });
533
- }
534
- return t.signal;
535
- }
536
- async function W(e) {
537
- let t = "";
538
- for await (const n of e) t += n.toString();
539
- return t;
540
- }
541
- var G = class {
542
- _process;
543
- _aborted = false;
544
- _options;
545
- _command;
546
- _args;
547
- _resolveClose;
548
- _processClosed;
549
- _thrownError;
550
- get process() {
551
- return this._process;
552
- }
553
- get pid() {
554
- return this._process?.pid;
555
- }
556
- get exitCode() {
557
- if (this._process && this._process.exitCode !== null) return this._process.exitCode;
558
- }
559
- constructor(e, t, n) {
560
- this._options = {
561
- ...B,
562
- ...n
563
- };
564
- this._command = e;
565
- this._args = t ?? [];
566
- this._processClosed = new Promise((e) => {
567
- this._resolveClose = e;
568
- });
569
- }
570
- kill(e) {
571
- return this._process?.kill(e) === true;
572
- }
573
- get aborted() {
574
- return this._aborted;
575
- }
576
- get killed() {
577
- return this._process?.killed === true;
578
- }
579
- pipe(e, t, n) {
580
- return q(e, t, {
581
- ...n,
582
- stdin: this
583
- });
584
- }
585
- async *[Symbol.asyncIterator]() {
586
- const e = this._process;
587
- if (!e) return;
588
- const t = [];
589
- if (this._streamErr) t.push(this._streamErr);
590
- if (this._streamOut) t.push(this._streamOut);
591
- const n = w(t);
592
- const r = c.createInterface({ input: n });
593
- for await (const e of r) yield e.toString();
594
- await this._processClosed;
595
- e.removeAllListeners();
596
- if (this._thrownError) throw this._thrownError;
597
- if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new z(this);
598
- }
599
- async _waitForOutput() {
600
- const e = this._process;
601
- if (!e) throw new Error("No process was started");
602
- const [t, n] = await Promise.all([this._streamOut ? W(this._streamOut) : "", this._streamErr ? W(this._streamErr) : ""]);
603
- await this._processClosed;
604
- if (this._options?.stdin) await this._options.stdin;
605
- e.removeAllListeners();
606
- if (this._thrownError) throw this._thrownError;
607
- const r = {
608
- stderr: n,
609
- stdout: t,
610
- exitCode: this.exitCode
611
- };
612
- if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new z(this, r);
613
- return r;
614
- }
615
- then(e, t) {
616
- return this._waitForOutput().then(e, t);
617
- }
618
- _streamOut;
619
- _streamErr;
620
- spawn() {
621
- const e = cwd();
622
- const n = this._options;
623
- const r = {
624
- ...V,
625
- ...n.nodeOptions
626
- };
627
- const i = [];
628
- this._resetState();
629
- if (n.timeout !== void 0) i.push(AbortSignal.timeout(n.timeout));
630
- if (n.signal !== void 0) i.push(n.signal);
631
- if (n.persist === true) r.detached = true;
632
- if (i.length > 0) r.signal = U(i);
633
- r.env = C(e, r.env);
634
- const { command: a, args: s } = H(this._command, this._args);
635
- const c = (0, R._parse)(a, s, r);
636
- const l = spawn(c.command, c.args, c.options);
637
- if (l.stderr) this._streamErr = l.stderr;
638
- if (l.stdout) this._streamOut = l.stdout;
639
- this._process = l;
640
- l.once("error", this._onError);
641
- l.once("close", this._onClose);
642
- if (n.stdin !== void 0 && l.stdin && n.stdin.process) {
643
- const { stdout: e } = n.stdin.process;
644
- if (e) e.pipe(l.stdin);
645
- }
646
- }
647
- _resetState() {
648
- this._aborted = false;
649
- this._processClosed = new Promise((e) => {
650
- this._resolveClose = e;
651
- });
652
- this._thrownError = void 0;
653
- }
654
- _onError = (e) => {
655
- if (e.name === "AbortError" && (!(e.cause instanceof Error) || e.cause.name !== "TimeoutError")) {
656
- this._aborted = true;
657
- return;
658
- }
659
- this._thrownError = e;
660
- };
661
- _onClose = () => {
662
- if (this._resolveClose) this._resolveClose();
663
- };
664
- };
665
- const K = (e, t, n) => {
666
- const r = new G(e, t, n);
667
- r.spawn();
668
- return r;
669
- };
670
- const q = K;
671
-
672
- //#endregion
673
- //#region src/shell/error.ts
674
- var ShellNonZeroExitError = class extends z {
675
- result;
676
- constructor(result, output) {
677
- super(result, output);
678
- this.result = result;
679
- }
680
- };
681
-
682
- //#endregion
683
- //#region src/shell/exec.ts
684
- const normalizeParams = (...params) => {
685
- const [commandOrTemplateOrOptions, argsOrTemplateValue, optionsOrTemplateValue, ...rest] = params;
686
- let command;
687
- let args;
688
- let options;
689
- let factory = false;
690
- if (isString(commandOrTemplateOrOptions)) {
691
- command = commandOrTemplateOrOptions;
692
- if (argsOrTemplateValue) args = argsOrTemplateValue;
693
- else {
694
- let tokens;
695
- try {
696
- tokens = tokenizeArgs(commandOrTemplateOrOptions);
697
- } catch (error) {
698
- throw new Error(`Failed to parse command string: "${commandOrTemplateOrOptions}". ${getErrorMessage(error)}`);
699
- }
700
- if (!tokens[0]) throw new Error(`Failed to extract command from string: "${commandOrTemplateOrOptions}"`);
701
- command = tokens[0];
702
- args = tokens.slice(1);
703
- }
704
- if (optionsOrTemplateValue) options = optionsOrTemplateValue;
705
- } else if (isArray(commandOrTemplateOrOptions)) {
706
- const input = concatTemplateStrings(commandOrTemplateOrOptions, [
707
- argsOrTemplateValue,
708
- optionsOrTemplateValue,
709
- ...rest
710
- ]);
711
- let tokens;
712
- try {
713
- tokens = tokenizeArgs(input);
714
- } catch (error) {
715
- throw new Error(`Failed to parse input template string: "${input}". ${getErrorMessage(error)}`);
716
- }
717
- if (!tokens[0]) throw new Error(`Failed to extract command from template string: "${input}"`);
718
- command = tokens[0];
719
- args = tokens.slice(1);
720
- } else if (isPlainObject(commandOrTemplateOrOptions)) {
721
- command = "";
722
- options = commandOrTemplateOrOptions;
723
- factory = true;
724
- } else throw new TypeError(`First parameter has an invalid type: "${typeof commandOrTemplateOrOptions}"`);
725
- return {
726
- command,
727
- args,
728
- options,
729
- factory
730
- };
731
- };
732
- var ShellExecProcess = class extends G {
733
- constructor(command, args, options) {
734
- const normalized = normalizeParams(command, args, options);
735
- super(normalized.command, normalized.args, normalized.options);
736
- }
737
- pipe(...params) {
738
- const { command, args, options, factory } = normalizeParams(...params);
739
- const pipeOptions = {
740
- ...options,
741
- stdin: this
742
- };
743
- if (!factory) return execImpl(command, args, pipeOptions);
744
- return (...params) => {
745
- const normalized = normalizeParams(...params, void 0);
746
- return execImpl(normalized.command, normalized.args, pipeOptions);
747
- };
748
- }
749
- async *[Symbol.asyncIterator]() {
750
- try {
751
- yield* super[Symbol.asyncIterator]();
752
- } catch (error) {
753
- if (error instanceof z) throw new ShellNonZeroExitError(this);
754
- throw error;
755
- }
756
- }
757
- async _waitForOutput() {
758
- try {
759
- return await super._waitForOutput();
760
- } catch (error) {
761
- if (error instanceof z) throw new ShellNonZeroExitError(this);
762
- throw error;
763
- }
764
- }
765
- };
766
- const exec = (...params) => {
767
- const { command, args, options, factory } = normalizeParams(...params);
768
- if (!factory) return execImpl(command, args, options);
769
- return (...params) => {
770
- const normalized = normalizeParams(...params, void 0);
771
- return execImpl(normalized.command, normalized.args, options);
772
- };
773
- };
774
- const execImpl = (...params) => {
775
- const p = new ShellExecProcess(...params);
776
- p.spawn();
777
- return p;
778
- };
779
-
780
- //#endregion
781
- export { exec as $, exec, exec as x, ShellExecProcess, ShellNonZeroExitError, tokenizeArgs as splitShellCommand };