Comparing version
import { ChildProcess, SpawnOptions } from 'node:child_process'; | ||
import { Readable } from 'node:stream'; | ||
declare class NonZeroExitError extends Error { | ||
readonly result: Result; | ||
readonly output?: Output; | ||
get exitCode(): number | undefined; | ||
constructor(result: Result, output?: Output); | ||
} | ||
interface Output { | ||
@@ -27,2 +34,3 @@ stderr: string; | ||
stdin: ExecProcess; | ||
throwOnError: boolean; | ||
} | ||
@@ -62,2 +70,2 @@ interface TinyExec { | ||
export { ExecProcess, type KillSignal, type Options, type Output, type OutputApi, type PipeOptions, type Result, type TinyExec, exec, x }; | ||
export { ExecProcess, type KillSignal, NonZeroExitError, type Options, type Output, type OutputApi, type PipeOptions, type Result, type TinyExec, exec, x }; |
377
dist/main.js
import { createRequire as __tinyexec_cr } from "node:module";const require = __tinyexec_cr(import.meta.url); | ||
var Ct = Object.create; | ||
var R = Object.defineProperty; | ||
var St = Object.getOwnPropertyDescriptor; | ||
var kt = Object.getOwnPropertyNames; | ||
var Tt = Object.getPrototypeOf, At = Object.prototype.hasOwnProperty; | ||
var m = /* @__PURE__ */ ((t) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(t, { | ||
var St = Object.create; | ||
var $ = Object.defineProperty; | ||
var kt = Object.getOwnPropertyDescriptor; | ||
var Tt = Object.getOwnPropertyNames; | ||
var At = Object.getPrototypeOf, Rt = Object.prototype.hasOwnProperty; | ||
var h = /* @__PURE__ */ ((t) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(t, { | ||
get: (e, n) => (typeof require < "u" ? require : e)[n] | ||
@@ -14,9 +14,9 @@ }) : t)(function(t) { | ||
var l = (t, e) => () => (e || t((e = { exports: {} }).exports, e), e.exports); | ||
var Rt = (t, e, n, r) => { | ||
var $t = (t, e, n, r) => { | ||
if (e && typeof e == "object" || typeof e == "function") | ||
for (let s of kt(e)) | ||
!At.call(t, s) && s !== n && R(t, s, { get: () => e[s], enumerable: !(r = St(e, s)) || r.enumerable }); | ||
for (let s of Tt(e)) | ||
!Rt.call(t, s) && s !== n && $(t, s, { get: () => e[s], enumerable: !(r = kt(e, s)) || r.enumerable }); | ||
return t; | ||
}; | ||
var $t = (t, e, n) => (n = t != null ? Ct(Tt(t)) : {}, Rt( | ||
var Nt = (t, e, n) => (n = t != null ? St(At(t)) : {}, $t( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
@@ -26,3 +26,3 @@ // file that has been converted to a CommonJS file using a Babel- | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
e || !t || !t.__esModule ? R(n, "default", { value: t, enumerable: !0 }) : n, | ||
e || !t || !t.__esModule ? $(n, "default", { value: t, enumerable: !0 }) : n, | ||
t | ||
@@ -32,7 +32,7 @@ )); | ||
// node_modules/isexe/windows.js | ||
var z = l((Ce, H) => { | ||
var W = l((Se, H) => { | ||
"use strict"; | ||
H.exports = F; | ||
F.sync = zt; | ||
var L = m("fs"); | ||
H.exports = z; | ||
z.sync = Wt; | ||
var j = h("fs"); | ||
function Ht(t, e) { | ||
@@ -49,12 +49,12 @@ var n = e.pathExt !== void 0 ? e.pathExt : process.env.PATHEXT; | ||
} | ||
function j(t, e, n) { | ||
function F(t, e, n) { | ||
return !t.isSymbolicLink() && !t.isFile() ? !1 : Ht(e, n); | ||
} | ||
function F(t, e, n) { | ||
L.stat(t, function(r, s) { | ||
n(r, r ? !1 : j(s, t, e)); | ||
function z(t, e, n) { | ||
j.stat(t, function(r, s) { | ||
n(r, r ? !1 : F(s, t, e)); | ||
}); | ||
} | ||
function zt(t, e) { | ||
return j(L.statSync(t), t, e); | ||
function Wt(t, e) { | ||
return F(j.statSync(t), t, e); | ||
} | ||
@@ -64,19 +64,19 @@ }); | ||
// node_modules/isexe/mode.js | ||
var B = l((Se, M) => { | ||
var X = l((ke, B) => { | ||
"use strict"; | ||
M.exports = D; | ||
D.sync = Wt; | ||
var W = m("fs"); | ||
function D(t, e, n) { | ||
W.stat(t, function(r, s) { | ||
n(r, r ? !1 : K(s, e)); | ||
B.exports = K; | ||
K.sync = Dt; | ||
var D = h("fs"); | ||
function K(t, e, n) { | ||
D.stat(t, function(r, s) { | ||
n(r, r ? !1 : M(s, e)); | ||
}); | ||
} | ||
function Wt(t, e) { | ||
return K(W.statSync(t), e); | ||
function Dt(t, e) { | ||
return M(D.statSync(t), e); | ||
} | ||
function K(t, e) { | ||
return t.isFile() && Dt(t, e); | ||
function M(t, e) { | ||
return t.isFile() && Kt(t, e); | ||
} | ||
function Dt(t, e) { | ||
function Kt(t, e) { | ||
var n = t.mode, r = t.uid, s = t.gid, o = e.uid !== void 0 ? e.uid : process.getuid && process.getuid(), i = e.gid !== void 0 ? e.gid : process.getgid && process.getgid(), u = parseInt("100", 8), c = parseInt("010", 8), a = parseInt("001", 8), f = u | c, p = n & a || n & c && s === i || n & u && r === o || n & f && o === 0; | ||
@@ -88,9 +88,9 @@ return p; | ||
// node_modules/isexe/index.js | ||
var G = l((Te, X) => { | ||
var U = l((Ae, G) => { | ||
"use strict"; | ||
var ke = m("fs"), w; | ||
process.platform === "win32" || global.TESTING_WINDOWS ? w = z() : w = B(); | ||
X.exports = b; | ||
b.sync = Kt; | ||
function b(t, e, n) { | ||
var Te = h("fs"), v; | ||
process.platform === "win32" || global.TESTING_WINDOWS ? v = W() : v = X(); | ||
G.exports = y; | ||
y.sync = Mt; | ||
function y(t, e, n) { | ||
if (typeof e == "function" && (n = e, e = {}), !n) { | ||
@@ -100,3 +100,3 @@ if (typeof Promise != "function") | ||
return new Promise(function(r, s) { | ||
b(t, e || {}, function(o, i) { | ||
y(t, e || {}, function(o, i) { | ||
o ? s(o) : r(i); | ||
@@ -106,9 +106,9 @@ }); | ||
} | ||
w(t, e || {}, function(r, s) { | ||
v(t, e || {}, function(r, s) { | ||
r && (r.code === "EACCES" || e && e.ignoreErrors) && (r = null, s = !1), n(r, s); | ||
}); | ||
} | ||
function Kt(t, e) { | ||
function Mt(t, e) { | ||
try { | ||
return w.sync(t, e || {}); | ||
return v.sync(t, e || {}); | ||
} catch (n) { | ||
@@ -123,6 +123,6 @@ if (e && e.ignoreErrors || n.code === "EACCES") | ||
// node_modules/which/which.js | ||
var tt = l((Ae, Z) => { | ||
var et = l((Re, tt) => { | ||
"use strict"; | ||
var g = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys", U = m("path"), Mt = g ? ";" : ":", Y = G(), V = (t) => Object.assign(new Error(`not found: ${t}`), { code: "ENOENT" }), J = (t, e) => { | ||
let n = e.colon || Mt, r = t.match(/\//) || g && t.match(/\\/) ? [""] : [ | ||
var g = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys", Y = h("path"), Bt = g ? ";" : ":", V = U(), J = (t) => Object.assign(new Error(`not found: ${t}`), { code: "ENOENT" }), Q = (t, e) => { | ||
let n = e.colon || Bt, r = t.match(/\//) || g && t.match(/\\/) ? [""] : [ | ||
// windows always checks the cwd first | ||
@@ -138,19 +138,19 @@ ...g ? [process.cwd()] : [], | ||
}; | ||
}, Q = (t, e, n) => { | ||
}, Z = (t, e, n) => { | ||
typeof e == "function" && (n = e, e = {}), e || (e = {}); | ||
let { pathEnv: r, pathExt: s, pathExtExe: o } = J(t, e), i = [], u = (a) => new Promise((f, p) => { | ||
let { pathEnv: r, pathExt: s, pathExtExe: o } = Q(t, e), i = [], u = (a) => new Promise((f, p) => { | ||
if (a === r.length) | ||
return e.all && i.length ? f(i) : p(V(t)); | ||
let d = r[a], v = /^".*"$/.test(d) ? d.slice(1, -1) : d, h = U.join(v, t), x = !v && /^\.[\\\/]/.test(t) ? t.slice(0, 2) + h : h; | ||
f(c(x, a, 0)); | ||
}), c = (a, f, p) => new Promise((d, v) => { | ||
return e.all && i.length ? f(i) : p(J(t)); | ||
let d = r[a], w = /^".*"$/.test(d) ? d.slice(1, -1) : d, m = Y.join(w, t), b = !w && /^\.[\\\/]/.test(t) ? t.slice(0, 2) + m : m; | ||
f(c(b, a, 0)); | ||
}), c = (a, f, p) => new Promise((d, w) => { | ||
if (p === s.length) | ||
return d(u(f + 1)); | ||
let h = s[p]; | ||
Y(a + h, { pathExt: o }, (x, Ot) => { | ||
if (!x && Ot) | ||
let m = s[p]; | ||
V(a + m, { pathExt: o }, (b, Ot) => { | ||
if (!b && Ot) | ||
if (e.all) | ||
i.push(a + h); | ||
i.push(a + m); | ||
else | ||
return d(a + h); | ||
return d(a + m); | ||
return d(c(a, f, p + 1)); | ||
@@ -160,11 +160,11 @@ }); | ||
return n ? u(0).then((a) => n(null, a), n) : u(0); | ||
}, Bt = (t, e) => { | ||
}, Xt = (t, e) => { | ||
e = e || {}; | ||
let { pathEnv: n, pathExt: r, pathExtExe: s } = J(t, e), o = []; | ||
let { pathEnv: n, pathExt: r, pathExtExe: s } = Q(t, e), o = []; | ||
for (let i = 0; i < n.length; i++) { | ||
let u = n[i], c = /^".*"$/.test(u) ? u.slice(1, -1) : u, a = U.join(c, t), f = !c && /^\.[\\\/]/.test(t) ? t.slice(0, 2) + a : a; | ||
let u = n[i], c = /^".*"$/.test(u) ? u.slice(1, -1) : u, a = Y.join(c, t), f = !c && /^\.[\\\/]/.test(t) ? t.slice(0, 2) + a : a; | ||
for (let p = 0; p < r.length; p++) { | ||
let d = f + r[p]; | ||
try { | ||
if (Y.sync(d, { pathExt: s })) | ||
if (V.sync(d, { pathExt: s })) | ||
if (e.all) | ||
@@ -182,24 +182,24 @@ o.push(d); | ||
return null; | ||
throw V(t); | ||
throw J(t); | ||
}; | ||
Z.exports = Q; | ||
Q.sync = Bt; | ||
tt.exports = Z; | ||
Z.sync = Xt; | ||
}); | ||
// node_modules/path-key/index.js | ||
var nt = l((Re, y) => { | ||
var rt = l(($e, _) => { | ||
"use strict"; | ||
var et = (t = {}) => { | ||
var nt = (t = {}) => { | ||
let e = t.env || process.env; | ||
return (t.platform || process.platform) !== "win32" ? "PATH" : Object.keys(e).reverse().find((r) => r.toUpperCase() === "PATH") || "Path"; | ||
}; | ||
y.exports = et; | ||
y.exports.default = et; | ||
_.exports = nt; | ||
_.exports.default = nt; | ||
}); | ||
// node_modules/cross-spawn/lib/util/resolveCommand.js | ||
var it = l(($e, ot) => { | ||
var ct = l((Ne, it) => { | ||
"use strict"; | ||
var rt = m("path"), Xt = tt(), Gt = nt(); | ||
function st(t, e) { | ||
var st = h("path"), Gt = et(), Ut = rt(); | ||
function ot(t, e) { | ||
let n = t.options.env || process.env, r = process.cwd(), s = t.options.cwd != null, o = s && process.chdir !== void 0 && !process.chdir.disabled; | ||
@@ -213,5 +213,5 @@ if (o) | ||
try { | ||
i = Xt.sync(t.command, { | ||
path: n[Gt({ env: n })], | ||
pathExt: e ? rt.delimiter : void 0 | ||
i = Gt.sync(t.command, { | ||
path: n[Ut({ env: n })], | ||
pathExt: e ? st.delimiter : void 0 | ||
}); | ||
@@ -222,36 +222,36 @@ } catch { | ||
} | ||
return i && (i = rt.resolve(s ? t.options.cwd : "", i)), i; | ||
return i && (i = st.resolve(s ? t.options.cwd : "", i)), i; | ||
} | ||
function Ut(t) { | ||
return st(t) || st(t, !0); | ||
function Yt(t) { | ||
return ot(t) || ot(t, !0); | ||
} | ||
ot.exports = Ut; | ||
it.exports = Yt; | ||
}); | ||
// node_modules/cross-spawn/lib/util/escape.js | ||
var ct = l((Ne, P) => { | ||
var at = l((qe, C) => { | ||
"use strict"; | ||
var _ = /([()\][%!^"`<>&|;, *?])/g; | ||
function Yt(t) { | ||
return t = t.replace(_, "^$1"), t; | ||
var P = /([()\][%!^"`<>&|;, *?])/g; | ||
function Vt(t) { | ||
return t = t.replace(P, "^$1"), t; | ||
} | ||
function Vt(t, e) { | ||
return t = `${t}`, t = t.replace(/(\\*)"/g, '$1$1\\"'), t = t.replace(/(\\*)$/, "$1$1"), t = `"${t}"`, t = t.replace(_, "^$1"), e && (t = t.replace(_, "^$1")), t; | ||
function Jt(t, e) { | ||
return t = `${t}`, t = t.replace(/(\\*)"/g, '$1$1\\"'), t = t.replace(/(\\*)$/, "$1$1"), t = `"${t}"`, t = t.replace(P, "^$1"), e && (t = t.replace(P, "^$1")), t; | ||
} | ||
P.exports.command = Yt; | ||
P.exports.argument = Vt; | ||
C.exports.command = Vt; | ||
C.exports.argument = Jt; | ||
}); | ||
// node_modules/shebang-regex/index.js | ||
var ut = l((qe, at) => { | ||
var lt = l((Ie, ut) => { | ||
"use strict"; | ||
at.exports = /^#!(.*)/; | ||
ut.exports = /^#!(.*)/; | ||
}); | ||
// node_modules/shebang-command/index.js | ||
var pt = l((Ie, lt) => { | ||
var dt = l((Le, pt) => { | ||
"use strict"; | ||
var Jt = ut(); | ||
lt.exports = (t = "") => { | ||
let e = t.match(Jt); | ||
var Qt = lt(); | ||
pt.exports = (t = "") => { | ||
let e = t.match(Qt); | ||
if (!e) | ||
@@ -265,6 +265,6 @@ return null; | ||
// node_modules/cross-spawn/lib/util/readShebang.js | ||
var ft = l((Le, dt) => { | ||
var ht = l((je, ft) => { | ||
"use strict"; | ||
var O = m("fs"), Qt = pt(); | ||
function Zt(t) { | ||
var O = h("fs"), Zt = dt(); | ||
function te(t) { | ||
let n = Buffer.alloc(150), r; | ||
@@ -275,23 +275,23 @@ try { | ||
} | ||
return Qt(n.toString()); | ||
return Zt(n.toString()); | ||
} | ||
dt.exports = Zt; | ||
ft.exports = te; | ||
}); | ||
// node_modules/cross-spawn/lib/parse.js | ||
var Et = l((je, gt) => { | ||
var wt = l((Fe, Et) => { | ||
"use strict"; | ||
var te = m("path"), mt = it(), ht = ct(), ee = ft(), ne = process.platform === "win32", re = /\.(?:com|exe)$/i, se = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i; | ||
function oe(t) { | ||
var ee = h("path"), mt = ct(), gt = at(), ne = ht(), re = process.platform === "win32", se = /\.(?:com|exe)$/i, oe = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i; | ||
function ie(t) { | ||
t.file = mt(t); | ||
let e = t.file && ee(t.file); | ||
let e = t.file && ne(t.file); | ||
return e ? (t.args.unshift(t.file), t.command = e, mt(t)) : t.file; | ||
} | ||
function ie(t) { | ||
if (!ne) | ||
function ce(t) { | ||
if (!re) | ||
return t; | ||
let e = oe(t), n = !re.test(e); | ||
let e = ie(t), n = !se.test(e); | ||
if (t.options.forceShell || n) { | ||
let r = se.test(e); | ||
t.command = te.normalize(t.command), t.command = ht.command(t.command), t.args = t.args.map((o) => ht.argument(o, r)); | ||
let r = oe.test(e); | ||
t.command = ee.normalize(t.command), t.command = gt.command(t.command), t.args = t.args.map((o) => gt.argument(o, r)); | ||
let s = [t.command].concat(t.args).join(" "); | ||
@@ -302,3 +302,3 @@ t.args = ["/d", "/s", "/c", `"${s}"`], t.command = process.env.comspec || "cmd.exe", t.options.windowsVerbatimArguments = !0; | ||
} | ||
function ce(t, e, n) { | ||
function ae(t, e, n) { | ||
e && !Array.isArray(e) && (n = e, e = null), e = e ? e.slice(0) : [], n = Object.assign({}, n); | ||
@@ -315,12 +315,12 @@ let r = { | ||
}; | ||
return n.shell ? r : ie(r); | ||
return n.shell ? r : ce(r); | ||
} | ||
gt.exports = ce; | ||
Et.exports = ae; | ||
}); | ||
// node_modules/cross-spawn/lib/enoent.js | ||
var xt = l((Fe, wt) => { | ||
var bt = l((ze, vt) => { | ||
"use strict"; | ||
var C = process.platform === "win32"; | ||
function S(t, e) { | ||
var S = process.platform === "win32"; | ||
function k(t, e) { | ||
return Object.assign(new Error(`${e} ${t.command} ENOENT`), { | ||
@@ -334,4 +334,4 @@ code: "ENOENT", | ||
} | ||
function ae(t, e) { | ||
if (!C) | ||
function ue(t, e) { | ||
if (!S) | ||
return; | ||
@@ -341,3 +341,3 @@ let n = t.emit; | ||
if (r === "exit") { | ||
let o = vt(s, e, "spawn"); | ||
let o = xt(s, e, "spawn"); | ||
if (o) | ||
@@ -349,13 +349,13 @@ return n.call(t, "error", o); | ||
} | ||
function vt(t, e) { | ||
return C && t === 1 && !e.file ? S(e.original, "spawn") : null; | ||
function xt(t, e) { | ||
return S && t === 1 && !e.file ? k(e.original, "spawn") : null; | ||
} | ||
function ue(t, e) { | ||
return C && t === 1 && !e.file ? S(e.original, "spawnSync") : null; | ||
function le(t, e) { | ||
return S && t === 1 && !e.file ? k(e.original, "spawnSync") : null; | ||
} | ||
wt.exports = { | ||
hookChildProcess: ae, | ||
verifyENOENT: vt, | ||
verifyENOENTSync: ue, | ||
notFoundError: S | ||
vt.exports = { | ||
hookChildProcess: ue, | ||
verifyENOENT: xt, | ||
verifyENOENTSync: le, | ||
notFoundError: k | ||
}; | ||
@@ -365,53 +365,53 @@ }); | ||
// node_modules/cross-spawn/index.js | ||
var _t = l((He, E) => { | ||
var Pt = l((He, E) => { | ||
"use strict"; | ||
var bt = m("child_process"), k = Et(), T = xt(); | ||
function yt(t, e, n) { | ||
let r = k(t, e, n), s = bt.spawn(r.command, r.args, r.options); | ||
return T.hookChildProcess(s, r), s; | ||
var yt = h("child_process"), T = wt(), A = bt(); | ||
function _t(t, e, n) { | ||
let r = T(t, e, n), s = yt.spawn(r.command, r.args, r.options); | ||
return A.hookChildProcess(s, r), s; | ||
} | ||
function le(t, e, n) { | ||
let r = k(t, e, n), s = bt.spawnSync(r.command, r.args, r.options); | ||
return s.error = s.error || T.verifyENOENTSync(s.status, r), s; | ||
function pe(t, e, n) { | ||
let r = T(t, e, n), s = yt.spawnSync(r.command, r.args, r.options); | ||
return s.error = s.error || A.verifyENOENTSync(s.status, r), s; | ||
} | ||
E.exports = yt; | ||
E.exports.spawn = yt; | ||
E.exports.sync = le; | ||
E.exports._parse = k; | ||
E.exports._enoent = T; | ||
E.exports = _t; | ||
E.exports.spawn = _t; | ||
E.exports.sync = pe; | ||
E.exports._parse = T; | ||
E.exports._enoent = A; | ||
}); | ||
// src/main.ts | ||
import { spawn as pe } from "child_process"; | ||
import { normalize as de } from "path"; | ||
import { cwd as fe } from "process"; | ||
import { spawn as de } from "child_process"; | ||
import { normalize as fe } from "path"; | ||
import { cwd as he } from "process"; | ||
// src/env.ts | ||
import { | ||
delimiter as $, | ||
resolve as Nt, | ||
dirname as qt | ||
delimiter as N, | ||
resolve as qt, | ||
dirname as It | ||
} from "path"; | ||
var It = /^path$/i, N = { key: "PATH", value: "" }; | ||
function Lt(t) { | ||
var Lt = /^path$/i, q = { key: "PATH", value: "" }; | ||
function jt(t) { | ||
for (let e in t) { | ||
if (!Object.prototype.hasOwnProperty.call(t, e) || !It.test(e)) | ||
if (!Object.prototype.hasOwnProperty.call(t, e) || !Lt.test(e)) | ||
continue; | ||
let n = t[e]; | ||
return n ? { key: e, value: n } : N; | ||
return n ? { key: e, value: n } : q; | ||
} | ||
return N; | ||
return q; | ||
} | ||
function jt(t, e) { | ||
let n = e.value.split($), r = t, s; | ||
function Ft(t, e) { | ||
let n = e.value.split(N), r = t, s; | ||
do | ||
n.push(Nt(r, "node_modules", ".bin")), s = r, r = qt(r); | ||
n.push(qt(r, "node_modules", ".bin")), s = r, r = It(r); | ||
while (r !== s); | ||
return { key: e.key, value: n.join($) }; | ||
return { key: e.key, value: n.join(N) }; | ||
} | ||
function q(t, e) { | ||
function I(t, e) { | ||
let n = { | ||
...process.env, | ||
...e | ||
}, r = jt(t, Lt(n)); | ||
}, r = Ft(t, jt(n)); | ||
return n[r.key] = r.value, n; | ||
@@ -421,5 +421,5 @@ } | ||
// src/stream.ts | ||
import { PassThrough as Ft } from "stream"; | ||
var I = (t) => { | ||
let e = t.length, n = new Ft(), r = () => { | ||
import { PassThrough as zt } from "stream"; | ||
var L = (t) => { | ||
let e = t.length, n = new zt(), r = () => { | ||
--e === 0 && n.emit("end"); | ||
@@ -433,17 +433,32 @@ }; | ||
// src/main.ts | ||
var Pt = $t(_t(), 1); | ||
var Ct = Nt(Pt(), 1); | ||
import me from "readline"; | ||
var he = { | ||
// src/non-zero-exit-error.ts | ||
var x = class extends Error { | ||
result; | ||
output; | ||
get exitCode() { | ||
if (this.result.exitCode !== null) | ||
return this.result.exitCode; | ||
} | ||
constructor(e, n) { | ||
super(`Process exited with non-zero status (${e.exitCode})`), this.result = e, this.output = n; | ||
} | ||
}; | ||
// src/main.ts | ||
var ge = { | ||
timeout: void 0, | ||
persist: !1 | ||
}, ge = { | ||
}, Ee = { | ||
windowsHide: !0 | ||
}; | ||
function Ee(t, e) { | ||
function we(t, e) { | ||
return { | ||
command: de(t), | ||
command: fe(t), | ||
args: e ?? [] | ||
}; | ||
} | ||
function ve(t) { | ||
function xe(t) { | ||
let e = new AbortController(); | ||
@@ -462,3 +477,3 @@ for (let n of t) { | ||
} | ||
var A = class { | ||
var R = class { | ||
_process; | ||
@@ -484,3 +499,3 @@ _aborted = !1; | ||
this._options = { | ||
...he, | ||
...ge, | ||
...r | ||
@@ -501,3 +516,3 @@ }, this._command = e, this._args = n ?? [], this._processClosed = new Promise((s) => { | ||
pipe(e, n, r) { | ||
return xe(e, n, { | ||
return be(e, n, { | ||
...r, | ||
@@ -513,3 +528,3 @@ stdin: this | ||
this._streamErr && n.push(this._streamErr), this._streamOut && n.push(this._streamOut); | ||
let r = I(n), s = me.createInterface({ | ||
let r = L(n), s = me.createInterface({ | ||
input: r | ||
@@ -521,2 +536,4 @@ }); | ||
throw this._thrownError; | ||
if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) | ||
throw new x(this); | ||
} | ||
@@ -536,6 +553,9 @@ async _waitForOutput() { | ||
throw this._thrownError; | ||
return { | ||
let s = { | ||
stderr: n, | ||
stdout: r | ||
}; | ||
if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) | ||
throw new x(this, s); | ||
return s; | ||
} | ||
@@ -548,8 +568,8 @@ then(e, n) { | ||
spawn() { | ||
let e = fe(), n = this._options, r = { | ||
...ge, | ||
let e = he(), n = this._options, r = { | ||
...Ee, | ||
...n.nodeOptions | ||
}, s = []; | ||
this._resetState(), n.timeout !== void 0 && s.push(AbortSignal.timeout(n.timeout)), n.signal !== void 0 && s.push(n.signal), n.persist === !0 && (r.detached = !0), s.length > 0 && (r.signal = ve(s)), r.env = q(e, r.env); | ||
let { command: o, args: i } = Ee(this._command, this._args), u = (0, Pt._parse)(o, i, r), c = pe( | ||
this._resetState(), n.timeout !== void 0 && s.push(AbortSignal.timeout(n.timeout)), n.signal !== void 0 && s.push(n.signal), n.persist === !0 && (r.detached = !0), s.length > 0 && (r.signal = xe(s)), r.env = I(e, r.env); | ||
let { command: o, args: i } = we(this._command, this._args), u = (0, Ct._parse)(o, i, r), c = de( | ||
u.command, | ||
@@ -579,10 +599,11 @@ u.args, | ||
}; | ||
}, we = (t, e, n) => { | ||
let r = new A(t, e, n); | ||
}, ve = (t, e, n) => { | ||
let r = new R(t, e, n); | ||
return r.spawn(), r; | ||
}, xe = we; | ||
}, be = ve; | ||
export { | ||
A as ExecProcess, | ||
xe as exec, | ||
we as x | ||
R as ExecProcess, | ||
x as NonZeroExitError, | ||
be as exec, | ||
ve as x | ||
}; |
{ | ||
"name": "tinyexec", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "A minimal library for executing processes in Node", |
@@ -56,2 +56,3 @@ # tinyexec 📟 | ||
- `nodeOptions` - any valid options to node's underlying `spawn` function | ||
- `throwOnError` - if true, non-zero exit codes will throw an error | ||
@@ -216,1 +217,24 @@ ### Piping to another process | ||
``` | ||
## Comparison with other libraries | ||
`tinyexec` aims to provide a lightweight layer on top of Node's own | ||
`child_process` API. | ||
Some clear benefits compared to other libraries are that `tinyexec` will be much lighter, have a much | ||
smaller footprint and will have a less abstract interface (less "magic"). It | ||
will also have equal security and cross-platform support to popular | ||
alternatives. | ||
There are various features other libraries include which we are unlikely | ||
to ever implement, as they would prevent us from providing a lightweight layer. | ||
For example, if you'd like write scripts rather than individual commands, and | ||
prefer to use templating, we'd definitely recommend | ||
[zx](https://github.com/google/zx). zx is a much higher level library which | ||
does some of the same work `tinyexec` does but behind a template string | ||
interface. | ||
Similarly, libraries like `execa` will provide helpers for various things | ||
like passing files as input to processes. We opt not to support features like | ||
this since many of them are easy to do yourself (using Node's own APIs). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
45385
6.65%1179
4.15%239
11.16%