+16
-1
| import { ChildProcess, SpawnOptions, SpawnSyncOptions } from "node:child_process"; | ||
| import { Readable } from "node:stream"; | ||
| //#region src/normalize.d.ts | ||
| interface NormalizedSpawnCommand { | ||
| command: string; | ||
| args: readonly string[]; | ||
| options: SpawnOptions; | ||
| } | ||
| /** | ||
| * Normalizes the command and arguments to work cross-platform. | ||
| * On Windows, this basically handles things like shebangs, calling | ||
| * `node_modules/.bin` commands, and escaping meta characters. | ||
| * On other platforms, it just returns the command and arguments as-is. | ||
| */ | ||
| declare function normalizeSpawnCommand(command: string, args?: readonly string[], options?: SpawnOptions): NormalizedSpawnCommand; | ||
| //#endregion | ||
| //#region src/non-zero-exit-error.d.ts | ||
@@ -37,2 +51,3 @@ declare class NonZeroExitError extends Error { | ||
| throwOnError: boolean; | ||
| nodePath: boolean; | ||
| } | ||
@@ -83,2 +98,2 @@ interface Options extends CommonOptions { | ||
| //#endregion | ||
| export { CommonOptions, CommonOutputApi, ExecProcess, KillSignal, NonZeroExitError, Options, Output, OutputApi, OutputApiSync, PipeOptions, Result, SyncOptions, SyncResult, TinyExec, exec, execSync, x, xSync }; | ||
| export { CommonOptions, CommonOutputApi, ExecProcess, KillSignal, NonZeroExitError, Options, Output, OutputApi, OutputApiSync, PipeOptions, Result, SyncOptions, SyncResult, TinyExec, exec, execSync, normalizeSpawnCommand, x, xSync }; |
+162
-456
@@ -1,23 +0,19 @@ | ||
| import { createRequire as e } from "node:module"; | ||
| import { spawn as t, spawnSync as n } from "node:child_process"; | ||
| import { cwd as r } from "node:process"; | ||
| import { delimiter as i, dirname as a, resolve as o } from "node:path"; | ||
| import { pipeline as s } from "node:stream/promises"; | ||
| import { PassThrough as c } from "node:stream"; | ||
| import l from "node:readline"; | ||
| //#region \0rolldown/runtime.js | ||
| var u = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports); | ||
| var d = /* @__PURE__ */ e(import.meta.url); | ||
| //#endregion | ||
| import { spawn as e, spawnSync as t } from "node:child_process"; | ||
| import { cwd as n } from "node:process"; | ||
| import { basename as r, delimiter as i, dirname as a, normalize as o, resolve as s } from "node:path"; | ||
| import { pipeline as c } from "node:stream/promises"; | ||
| import { PassThrough as l } from "node:stream"; | ||
| import u from "node:readline"; | ||
| import { closeSync as d, openSync as f, readSync as p, statSync as m } from "node:fs"; | ||
| //#region src/env.ts | ||
| const f = /^path$/i; | ||
| const p = { | ||
| const h = /^path$/i; | ||
| const g = { | ||
| key: "PATH", | ||
| value: "" | ||
| }; | ||
| function m(e) { | ||
| function _(e) { | ||
| for (const t in e) { | ||
| if (!Object.prototype.hasOwnProperty.call(e, t) || !f.test(t)) continue; | ||
| if (!Object.prototype.hasOwnProperty.call(e, t) || !h.test(t)) continue; | ||
| const n = e[t]; | ||
| if (!n) return p; | ||
| if (!n) return g; | ||
| return { | ||
@@ -28,14 +24,14 @@ key: t, | ||
| } | ||
| return p; | ||
| return g; | ||
| } | ||
| function h(e, t) { | ||
| function v(e, t) { | ||
| const n = t.value.split(i); | ||
| const r = []; | ||
| let s = e; | ||
| let o = e; | ||
| let c; | ||
| do { | ||
| r.push(o(s, "node_modules", ".bin")); | ||
| c = s; | ||
| s = a(s); | ||
| } while (s !== c); | ||
| r.push(s(o, "node_modules", ".bin")); | ||
| c = o; | ||
| o = a(o); | ||
| } while (o !== c); | ||
| r.push(a(process.execPath)); | ||
@@ -48,422 +44,132 @@ const l = r.concat(n).join(i); | ||
| } | ||
| function g(e, t) { | ||
| const n = { | ||
| function y(e, t, n = true) { | ||
| const r = { | ||
| ...process.env, | ||
| ...t | ||
| }; | ||
| const r = h(e, m(n)); | ||
| n[r.key] = r.value; | ||
| return n; | ||
| if (!n) return r; | ||
| const i = v(e, _(r)); | ||
| r[i.key] = i.value; | ||
| return r; | ||
| } | ||
| //#endregion | ||
| //#region src/stream.ts | ||
| const _ = (e) => { | ||
| const b = (e) => { | ||
| let t = e.length; | ||
| const n = new c(); | ||
| const n = new l(); | ||
| const r = () => { | ||
| if (--t === 0) n.end(); | ||
| }; | ||
| for (const t of e) s(t, n, { end: false }).then(r).catch(r); | ||
| for (const t of e) c(t, n, { end: false }).then(r).catch(r); | ||
| return n; | ||
| }; | ||
| //#endregion | ||
| //#region node_modules/isexe/windows.js | ||
| var v = /* @__PURE__ */ u(((e, t) => { | ||
| t.exports = a; | ||
| a.sync = o; | ||
| var n = d("fs"); | ||
| function r(e, t) { | ||
| var n = t.pathExt !== void 0 ? t.pathExt : process.env.PATHEXT; | ||
| if (!n) return true; | ||
| n = n.split(";"); | ||
| if (n.indexOf("") !== -1) return true; | ||
| for (var r = 0; r < n.length; r++) { | ||
| var i = n[r].toLowerCase(); | ||
| if (i && e.substr(-i.length).toLowerCase() === i) return true; | ||
| } | ||
| return false; | ||
| } | ||
| function i(e, t, n) { | ||
| if (!e.isSymbolicLink() && !e.isFile()) return false; | ||
| return r(t, n); | ||
| } | ||
| function a(e, t, r) { | ||
| n.stat(e, function(n, a) { | ||
| r(n, n ? false : i(a, e, t)); | ||
| }); | ||
| } | ||
| function o(e, t) { | ||
| return i(n.statSync(e), e, t); | ||
| } | ||
| })); | ||
| //#endregion | ||
| //#region node_modules/isexe/mode.js | ||
| var y = /* @__PURE__ */ u(((e, t) => { | ||
| t.exports = r; | ||
| r.sync = i; | ||
| var n = d("fs"); | ||
| function r(e, t, r) { | ||
| n.stat(e, function(e, n) { | ||
| r(e, e ? false : a(n, t)); | ||
| }); | ||
| } | ||
| function i(e, t) { | ||
| return a(n.statSync(e), t); | ||
| } | ||
| function a(e, t) { | ||
| return e.isFile() && o(e, t); | ||
| } | ||
| function o(e, t) { | ||
| var n = e.mode; | ||
| var r = e.uid; | ||
| var i = e.gid; | ||
| var a = t.uid !== void 0 ? t.uid : process.getuid && process.getuid(); | ||
| var o = t.gid !== void 0 ? t.gid : process.getgid && process.getgid(); | ||
| var s = parseInt("100", 8); | ||
| var c = parseInt("010", 8); | ||
| var l = parseInt("001", 8); | ||
| var u = s | c; | ||
| return n & l || n & c && i === o || n & s && r === a || n & u && a === 0; | ||
| } | ||
| })); | ||
| //#endregion | ||
| //#region node_modules/isexe/index.js | ||
| var b = /* @__PURE__ */ u(((e, t) => { | ||
| d("fs"); | ||
| var n; | ||
| if (process.platform === "win32" || global.TESTING_WINDOWS) n = v(); | ||
| else n = y(); | ||
| t.exports = r; | ||
| r.sync = i; | ||
| function r(e, t, i) { | ||
| if (typeof t === "function") { | ||
| i = t; | ||
| t = {}; | ||
| } | ||
| if (!i) { | ||
| if (typeof Promise !== "function") throw new TypeError("callback not provided"); | ||
| return new Promise(function(n, i) { | ||
| r(e, t || {}, function(e, t) { | ||
| if (e) i(e); | ||
| else n(t); | ||
| }); | ||
| }); | ||
| } | ||
| n(e, t || {}, function(e, n) { | ||
| if (e) { | ||
| if (e.code === "EACCES" || t && t.ignoreErrors) { | ||
| e = null; | ||
| n = false; | ||
| } | ||
| } | ||
| i(e, n); | ||
| }); | ||
| } | ||
| function i(e, t) { | ||
| try { | ||
| return n.sync(e, t || {}); | ||
| } catch (e) { | ||
| if (t && t.ignoreErrors || e.code === "EACCES") return false; | ||
| else throw e; | ||
| } | ||
| } | ||
| })); | ||
| //#endregion | ||
| //#region node_modules/which/which.js | ||
| var x = /* @__PURE__ */ u(((e, t) => { | ||
| const n = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys"; | ||
| const r = d("path"); | ||
| const i = n ? ";" : ":"; | ||
| const a = b(); | ||
| const o = (e) => Object.assign(/* @__PURE__ */ new Error(`not found: ${e}`), { code: "ENOENT" }); | ||
| const s = (e, t) => { | ||
| const r = t.colon || i; | ||
| const a = e.match(/\//) || n && e.match(/\\/) ? [""] : [...n ? [process.cwd()] : [], ...(t.path || process.env.PATH || "").split(r)]; | ||
| const o = n ? t.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : ""; | ||
| const s = n ? o.split(r) : [""]; | ||
| if (n) { | ||
| if (e.indexOf(".") !== -1 && s[0] !== "") s.unshift(""); | ||
| } | ||
| return { | ||
| pathEnv: a, | ||
| pathExt: s, | ||
| pathExtExe: o | ||
| }; | ||
| //#region src/normalize.ts | ||
| const x = /([()\][%!^"`<>&|;, *?])/g; | ||
| const S = /^#!\s*(.+)$/; | ||
| const C = /\.(?:com|exe)$/i; | ||
| const w = /node_modules[\\/]\.bin[\\/][^\\/]+\.cmd$/i; | ||
| const T = process.platform === "win32"; | ||
| const E = [ | ||
| ".EXE", | ||
| ".CMD", | ||
| ".BAT", | ||
| ".COM" | ||
| ]; | ||
| /** | ||
| * Normalizes the command and arguments to work cross-platform. | ||
| * On Windows, this basically handles things like shebangs, calling | ||
| * `node_modules/.bin` commands, and escaping meta characters. | ||
| * On other platforms, it just returns the command and arguments as-is. | ||
| */ | ||
| function D(e, t = [], n = {}) { | ||
| if (n.shell === true || !T) return { | ||
| command: e, | ||
| args: t, | ||
| options: n | ||
| }; | ||
| const c = (e, t, n) => { | ||
| if (typeof t === "function") { | ||
| n = t; | ||
| t = {}; | ||
| } | ||
| if (!t) t = {}; | ||
| const { pathEnv: i, pathExt: c, pathExtExe: l } = s(e, t); | ||
| const u = []; | ||
| const d = (n) => new Promise((a, s) => { | ||
| if (n === i.length) return t.all && u.length ? a(u) : s(o(e)); | ||
| const c = i[n]; | ||
| const l = /^".*"$/.test(c) ? c.slice(1, -1) : c; | ||
| const d = r.join(l, e); | ||
| a(f(!l && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d, n, 0)); | ||
| }); | ||
| const f = (e, n, r) => new Promise((i, o) => { | ||
| if (r === c.length) return i(d(n + 1)); | ||
| const s = c[r]; | ||
| a(e + s, { pathExt: l }, (a, o) => { | ||
| if (!a && o) if (t.all) u.push(e + s); | ||
| else return i(e + s); | ||
| return i(f(e, n, r + 1)); | ||
| }); | ||
| }); | ||
| return n ? d(0).then((e) => n(null, e), n) : d(0); | ||
| }; | ||
| const l = (e, t) => { | ||
| t = t || {}; | ||
| const { pathEnv: n, pathExt: i, pathExtExe: c } = s(e, t); | ||
| const l = []; | ||
| for (let o = 0; o < n.length; o++) { | ||
| const s = n[o]; | ||
| const u = /^".*"$/.test(s) ? s.slice(1, -1) : s; | ||
| const d = r.join(u, e); | ||
| const f = !u && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d; | ||
| for (let e = 0; e < i.length; e++) { | ||
| const n = f + i[e]; | ||
| try { | ||
| if (a.sync(n, { pathExt: c })) if (t.all) l.push(n); | ||
| else return n; | ||
| } catch (e) {} | ||
| } | ||
| } | ||
| if (t.all && l.length) return l; | ||
| if (t.nothrow) return null; | ||
| throw o(e); | ||
| }; | ||
| t.exports = c; | ||
| c.sync = l; | ||
| })); | ||
| //#endregion | ||
| //#region node_modules/path-key/index.js | ||
| var S = /* @__PURE__ */ u(((e, t) => { | ||
| const n = (e = {}) => { | ||
| const t = e.env || process.env; | ||
| if ((e.platform || process.platform) !== "win32") return "PATH"; | ||
| return Object.keys(t).reverse().find((e) => e.toUpperCase() === "PATH") || "Path"; | ||
| }; | ||
| t.exports = n; | ||
| t.exports.default = n; | ||
| })); | ||
| //#endregion | ||
| //#region node_modules/cross-spawn/lib/util/resolveCommand.js | ||
| var C = /* @__PURE__ */ u(((e, t) => { | ||
| const n = d("path"); | ||
| const r = x(); | ||
| const i = S(); | ||
| function a(e, t) { | ||
| const a = e.options.env || process.env; | ||
| const o = process.cwd(); | ||
| const s = e.options.cwd != null; | ||
| const c = s && process.chdir !== void 0 && !process.chdir.disabled; | ||
| if (c) try { | ||
| process.chdir(e.options.cwd); | ||
| } catch (e) {} | ||
| let l; | ||
| let i = O(e, n); | ||
| let a = null; | ||
| if (i !== null) { | ||
| const e = 150; | ||
| const t = Buffer.alloc(e); | ||
| let n = null; | ||
| try { | ||
| l = r.sync(e.command, { | ||
| path: a[i({ env: a })], | ||
| pathExt: t ? n.delimiter : void 0 | ||
| }); | ||
| } catch (e) {} finally { | ||
| if (c) process.chdir(o); | ||
| n = f(i, "r"); | ||
| p(n, t, 0, e, 0); | ||
| } catch {} finally { | ||
| if (n !== null) d(n); | ||
| } | ||
| if (l) l = n.resolve(s ? e.options.cwd : "", l); | ||
| return l; | ||
| } | ||
| function o(e) { | ||
| return a(e) || a(e, true); | ||
| } | ||
| t.exports = o; | ||
| })); | ||
| //#endregion | ||
| //#region node_modules/cross-spawn/lib/util/escape.js | ||
| var w = /* @__PURE__ */ u(((e, t) => { | ||
| const n = /([()\][%!^"`<>&|;, *?])/g; | ||
| function r(e) { | ||
| e = e.replace(n, "^$1"); | ||
| return e; | ||
| } | ||
| function i(e, t) { | ||
| e = `${e}`; | ||
| e = e.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\""); | ||
| e = e.replace(/(?=(\\+?)?)\1$/, "$1$1"); | ||
| e = `"${e}"`; | ||
| e = e.replace(n, "^$1"); | ||
| if (t) e = e.replace(n, "^$1"); | ||
| return e; | ||
| } | ||
| t.exports.command = r; | ||
| t.exports.argument = i; | ||
| })); | ||
| //#endregion | ||
| //#region node_modules/shebang-regex/index.js | ||
| var T = /* @__PURE__ */ u(((e, t) => { | ||
| t.exports = /^#!(.*)/; | ||
| })); | ||
| //#endregion | ||
| //#region node_modules/shebang-command/index.js | ||
| var E = /* @__PURE__ */ u(((e, t) => { | ||
| const n = T(); | ||
| t.exports = (e = "") => { | ||
| const t = e.match(n); | ||
| if (!t) return null; | ||
| const [r, i] = t[0].replace(/#! ?/, "").split(" "); | ||
| const a = r.split("/").pop(); | ||
| if (a === "env") return i; | ||
| return i ? `${a} ${i}` : a; | ||
| }; | ||
| })); | ||
| //#endregion | ||
| //#region node_modules/cross-spawn/lib/util/readShebang.js | ||
| var D = /* @__PURE__ */ u(((e, t) => { | ||
| const n = d("fs"); | ||
| const r = E(); | ||
| function i(e) { | ||
| const t = 150; | ||
| const i = Buffer.alloc(t); | ||
| let a; | ||
| try { | ||
| a = n.openSync(e, "r"); | ||
| n.readSync(a, i, 0, t, 0); | ||
| n.closeSync(a); | ||
| } catch (e) {} | ||
| return r(i.toString()); | ||
| } | ||
| t.exports = i; | ||
| })); | ||
| //#endregion | ||
| //#region node_modules/cross-spawn/lib/parse.js | ||
| var O = /* @__PURE__ */ u(((e, t) => { | ||
| const n = d("path"); | ||
| const r = C(); | ||
| const i = w(); | ||
| const a = D(); | ||
| const o = process.platform === "win32"; | ||
| const s = /\.(?:com|exe)$/i; | ||
| const c = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i; | ||
| function l(e) { | ||
| e.file = r(e); | ||
| const t = e.file && a(e.file); | ||
| if (t) { | ||
| e.args.unshift(e.file); | ||
| e.command = t; | ||
| return r(e); | ||
| const o = t.toString().match(S); | ||
| if (o !== null) { | ||
| const e = o[1].trim(); | ||
| const t = e.indexOf(" "); | ||
| const n = t !== -1 ? e.slice(0, t) : e; | ||
| const i = t !== -1 ? e.slice(t + 1) : ""; | ||
| const s = r(n); | ||
| a = s === "env" ? i || null : s; | ||
| } | ||
| return e.file; | ||
| } | ||
| function u(e) { | ||
| if (!o) return e; | ||
| const t = l(e); | ||
| const r = !s.test(t); | ||
| if (e.options.forceShell || r) { | ||
| const r = c.test(t); | ||
| e.command = n.normalize(e.command); | ||
| e.command = i.command(e.command); | ||
| e.args = e.args.map((e) => i.argument(e, r)); | ||
| e.args = [ | ||
| "/d", | ||
| "/s", | ||
| "/c", | ||
| `"${[e.command].concat(e.args).join(" ")}"` | ||
| ]; | ||
| e.command = process.env.comspec || "cmd.exe"; | ||
| e.options.windowsVerbatimArguments = true; | ||
| } | ||
| return e; | ||
| if (a !== null && i !== null) { | ||
| t = [i, ...t]; | ||
| e = a; | ||
| i = O(e, n); | ||
| } | ||
| function f(e, t, n) { | ||
| if (t && !Array.isArray(t)) { | ||
| n = t; | ||
| t = null; | ||
| } | ||
| t = t ? t.slice(0) : []; | ||
| n = Object.assign({}, n); | ||
| const r = { | ||
| command: e, | ||
| args: t, | ||
| options: n, | ||
| file: void 0, | ||
| original: { | ||
| command: e, | ||
| args: t | ||
| } | ||
| }; | ||
| return n.shell ? r : u(r); | ||
| } | ||
| t.exports = f; | ||
| })); | ||
| //#endregion | ||
| //#region node_modules/cross-spawn/lib/enoent.js | ||
| var k = /* @__PURE__ */ u(((e, t) => { | ||
| const n = process.platform === "win32"; | ||
| function r(e, t) { | ||
| return Object.assign(/* @__PURE__ */ new Error(`${t} ${e.command} ENOENT`), { | ||
| code: "ENOENT", | ||
| errno: "ENOENT", | ||
| syscall: `${t} ${e.command}`, | ||
| path: e.command, | ||
| spawnargs: e.args | ||
| if (i === null || !C.test(i)) { | ||
| const r = i !== null && w.test(i); | ||
| e = o(e); | ||
| e = e.replace(x, "^$1"); | ||
| t = t.map((e) => { | ||
| e = e.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\""); | ||
| e = e.replace(/(?=(\\+?)?)\1$/, "$1$1"); | ||
| e = `"${e}"`; | ||
| e = e.replace(x, "^$1"); | ||
| if (r) e = e.replace(x, "^$1"); | ||
| return e; | ||
| }); | ||
| } | ||
| function i(e, t) { | ||
| if (!n) return; | ||
| const r = e.emit; | ||
| e.emit = function(n, i) { | ||
| if (n === "exit") { | ||
| const n = a(i, t); | ||
| if (n) return r.call(e, "error", n); | ||
| } | ||
| return r.apply(e, arguments); | ||
| t = [ | ||
| "/d", | ||
| "/s", | ||
| "/c", | ||
| `"${[e, ...t].join(" ")}"` | ||
| ]; | ||
| e = n.env?.comspec ?? "cmd.exe"; | ||
| n = { | ||
| ...n, | ||
| windowsVerbatimArguments: true | ||
| }; | ||
| } | ||
| function a(e, t) { | ||
| if (n && e === 1 && !t.file) return r(t.original, "spawn"); | ||
| return null; | ||
| } | ||
| function o(e, t) { | ||
| if (n && e === 1 && !t.file) return r(t.original, "spawnSync"); | ||
| return null; | ||
| } | ||
| t.exports = { | ||
| hookChildProcess: i, | ||
| verifyENOENT: a, | ||
| verifyENOENTSync: o, | ||
| notFoundError: r | ||
| return { | ||
| command: e, | ||
| args: t, | ||
| options: n | ||
| }; | ||
| })); | ||
| //#endregion | ||
| //#region node_modules/cross-spawn/index.js | ||
| var A = /* @__PURE__ */ u(((e, t) => { | ||
| const n = d("child_process"); | ||
| const r = O(); | ||
| const i = k(); | ||
| function a(e, t, a) { | ||
| const o = r(e, t, a); | ||
| const s = n.spawn(o.command, o.args, o.options); | ||
| i.hookChildProcess(s, o); | ||
| return s; | ||
| } | ||
| /** | ||
| * Resolves the command to an absolute path if possible. | ||
| * Handles things like traversing PATH and adding extensions from PATHEXT | ||
| */ | ||
| function O(e, t) { | ||
| const r = (t.cwd ?? n()).toString(); | ||
| const a = t.env ?? process.env; | ||
| const o = _(a).value; | ||
| const c = e.includes("/") || e.includes("\\") ? [""] : [r, ...o.split(i)]; | ||
| const l = a.PATHEXT ? a.PATHEXT.split(i) : E; | ||
| if (e.includes(".") && l[0] !== "") l.unshift(""); | ||
| for (const t of c) { | ||
| const n = s(r, t.startsWith("\"") && t.endsWith("\"") && t.length > 1 ? t.slice(1, -1) : t, e); | ||
| for (const e of l) { | ||
| const t = n + e; | ||
| try { | ||
| if (m(t).isFile()) return t; | ||
| } catch {} | ||
| } | ||
| } | ||
| function o(e, t, a) { | ||
| const o = r(e, t, a); | ||
| const s = n.spawnSync(o.command, o.args, o.options); | ||
| s.error = s.error || i.verifyENOENTSync(s.status, o); | ||
| return s; | ||
| } | ||
| t.exports = a; | ||
| t.exports.spawn = a; | ||
| t.exports.sync = o; | ||
| t.exports._parse = r; | ||
| t.exports._enoent = i; | ||
| })); | ||
| return null; | ||
| } | ||
| //#endregion | ||
| //#region src/non-zero-exit-error.ts | ||
| var j = A(); | ||
| var M = class extends Error { | ||
| var k = class extends Error { | ||
| result; | ||
| output; | ||
| get exitCode() { | ||
@@ -480,10 +186,10 @@ if (this.result.exitCode !== null) return this.result.exitCode; | ||
| //#region src/main.ts | ||
| const N = /\r?\n/; | ||
| const P = { | ||
| const A = /\r?\n/; | ||
| const j = { | ||
| timeout: void 0, | ||
| persist: false | ||
| }; | ||
| const F = { timeout: void 0 }; | ||
| const I = { windowsHide: true }; | ||
| function L(e) { | ||
| const M = { timeout: void 0 }; | ||
| const N = { windowsHide: true }; | ||
| function P(e) { | ||
| const t = new AbortController(); | ||
@@ -502,3 +208,3 @@ for (const n of e) { | ||
| } | ||
| async function R(e) { | ||
| async function F(e) { | ||
| let t = ""; | ||
@@ -510,3 +216,3 @@ try { | ||
| } | ||
| var z = class { | ||
| var I = class { | ||
| _process; | ||
@@ -531,3 +237,3 @@ _aborted = false; | ||
| this._options = { | ||
| ...P, | ||
| ...j, | ||
| ...n | ||
@@ -551,3 +257,3 @@ }; | ||
| pipe(e, t, n) { | ||
| return H(e, t, { | ||
| return z(e, t, { | ||
| ...n, | ||
@@ -563,4 +269,4 @@ stdin: this | ||
| if (this._streamOut) t.push(this._streamOut); | ||
| const n = _(t); | ||
| const r = l.createInterface({ input: n }); | ||
| const n = b(t); | ||
| const r = u.createInterface({ input: n }); | ||
| for await (const e of r) yield e.toString(); | ||
@@ -570,3 +276,3 @@ await this._processClosed; | ||
| if (this._thrownError) throw this._thrownError; | ||
| if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new M(this); | ||
| if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new k(this); | ||
| } | ||
@@ -576,3 +282,3 @@ async _waitForOutput() { | ||
| if (!e) throw new Error("No process was started"); | ||
| const [t, n] = await Promise.all([this._streamOut ? R(this._streamOut) : "", this._streamErr ? R(this._streamErr) : ""]); | ||
| const [t, n] = await Promise.all([this._streamOut ? F(this._streamOut) : "", this._streamErr ? F(this._streamErr) : ""]); | ||
| await this._processClosed; | ||
@@ -588,3 +294,3 @@ const { stdin: r } = this._options; | ||
| }; | ||
| if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new M(this, i); | ||
| if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new k(this, i); | ||
| return i; | ||
@@ -598,17 +304,17 @@ } | ||
| spawn() { | ||
| const e = r(); | ||
| const n = this._options; | ||
| const t = n(); | ||
| const r = this._options; | ||
| const i = { | ||
| ...I, | ||
| ...n.nodeOptions | ||
| ...N, | ||
| ...r.nodeOptions | ||
| }; | ||
| const a = []; | ||
| this._resetState(); | ||
| if (n.timeout !== void 0) a.push(AbortSignal.timeout(n.timeout)); | ||
| if (n.signal !== void 0) a.push(n.signal); | ||
| if (n.persist === true) i.detached = true; | ||
| if (a.length > 0) i.signal = L(a); | ||
| i.env = g(e, i.env); | ||
| const o = (0, j._parse)(this._command, this._args, i); | ||
| const s = t(o.command, o.args, o.options); | ||
| if (r.timeout !== void 0) a.push(AbortSignal.timeout(r.timeout)); | ||
| if (r.signal !== void 0) a.push(r.signal); | ||
| if (r.persist === true) i.detached = true; | ||
| if (a.length > 0) i.signal = P(a); | ||
| i.env = y(t, i.env, r.nodePath); | ||
| const o = D(this._command, this._args, i); | ||
| const s = e(o.command, o.args, o.options); | ||
| if (s.stderr) this._streamErr = s.stderr; | ||
@@ -620,3 +326,3 @@ if (s.stdout) this._streamOut = s.stdout; | ||
| if (s.stdin) { | ||
| const { stdin: e } = n; | ||
| const { stdin: e } = r; | ||
| if (typeof e === "string") s.stdin.end(e); | ||
@@ -644,8 +350,8 @@ else e?.process?.stdout?.pipe(s.stdin); | ||
| }; | ||
| function B(e, t, i) { | ||
| function L(e, r, i) { | ||
| const a = { | ||
| ...F, | ||
| ...M, | ||
| ...i | ||
| }; | ||
| const o = r(); | ||
| const o = n(); | ||
| const s = { | ||
@@ -656,5 +362,5 @@ windowsHide: true, | ||
| if (a.timeout !== void 0) s.timeout = a.timeout; | ||
| s.env = g(o, s.env); | ||
| const c = (0, j._parse)(e, t ?? [], s); | ||
| const l = n(c.command, c.args, c.options); | ||
| s.env = y(o, s.env, a.nodePath); | ||
| const c = D(e, r ?? [], s); | ||
| const l = t(c.command, c.args, c.options); | ||
| if (l.error) throw l.error; | ||
@@ -680,3 +386,3 @@ const u = l.stdout?.toString() ?? ""; | ||
| if (!e) continue; | ||
| const t = e.split(N); | ||
| const t = e.split(A); | ||
| if (t[t.length - 1] === "") t.pop(); | ||
@@ -687,13 +393,13 @@ yield* t; | ||
| }; | ||
| if (a.throwOnError && f !== 0 && f !== void 0) throw new M(m, m); | ||
| if (a.throwOnError && f !== 0 && f !== void 0) throw new k(m, m); | ||
| return m; | ||
| } | ||
| const V = (e, t, n) => { | ||
| const r = new z(e, t, n); | ||
| const R = (e, t, n) => { | ||
| const r = new I(e, t, n); | ||
| r.spawn(); | ||
| return r; | ||
| }; | ||
| const H = V; | ||
| const U = B; | ||
| const z = R; | ||
| const B = L; | ||
| //#endregion | ||
| export { z as ExecProcess, M as NonZeroExitError, H as exec, U as execSync, V as x, B as xSync }; | ||
| export { I as ExecProcess, k as NonZeroExitError, z as exec, B as execSync, D as normalizeSpawnCommand, R as x, L as xSync }; |
+12
-14
| { | ||
| "name": "tinyexec", | ||
| "version": "1.1.2", | ||
| "version": "1.2.0", | ||
| "type": "module", | ||
@@ -11,13 +11,14 @@ "description": "A minimal library for executing processes in Node", | ||
| "files": [ | ||
| "dist" | ||
| "dist", | ||
| "THIRD-PARTY-LICENSES.txt" | ||
| ], | ||
| "scripts": { | ||
| "build": "tsdown", | ||
| "build:types": "tsc", | ||
| "dev": "tsdown --watch", | ||
| "format": "prettier --write src", | ||
| "format:check": "prettier --check src", | ||
| "lint": "eslint src && publint", | ||
| "lint": "tsc --noEmit && eslint src && publint", | ||
| "prepare": "npm run build", | ||
| "test": "npm run build && vitest run" | ||
| "test": "npm run build && npm run test:unit", | ||
| "test:unit": "vitest run" | ||
| }, | ||
@@ -43,13 +44,10 @@ "repository": { | ||
| "@eslint/js": "^10.0.1", | ||
| "@types/cross-spawn": "^6.0.6", | ||
| "@types/node": "^25.6.0", | ||
| "@vitest/coverage-v8": "^4.1.5", | ||
| "cross-spawn": "^7.0.6", | ||
| "eslint": "^10.2.1", | ||
| "@types/node": "^25.9.0", | ||
| "@vitest/coverage-v8": "^4.1.6", | ||
| "eslint": "^10.4.0", | ||
| "prettier": "^3.8.3", | ||
| "publint": "^0.3.18", | ||
| "rollup-plugin-license": "^3.7.1", | ||
| "tsdown": "^0.21.10", | ||
| "publint": "^0.3.21", | ||
| "tsdown": "^0.22.0", | ||
| "typescript": "^6.0.3", | ||
| "typescript-eslint": "^8.59.1", | ||
| "typescript-eslint": "^8.59.4", | ||
| "vitest": "^4.0.7" | ||
@@ -56,0 +54,0 @@ }, |
+8
-0
@@ -66,2 +66,3 @@ # tinyexec 📟 | ||
| - `throwOnError` - if true, non-zero exit codes will throw an error | ||
| - `nodePath` - if `false`, `node_modules/.bin` directories and the current node executable's directory will not be prepended to `PATH` (defaults to `true`) | ||
@@ -127,2 +128,9 @@ ### Passing a string to stdin | ||
| If you'd rather not have `node_modules/.bin` (or the directory of the current | ||
| `node` executable) prepended to `PATH`, pass `nodePath: false`: | ||
| ```ts | ||
| await x('eslint', ['.'], {nodePath: false}); | ||
| ``` | ||
| ### Using an abort signal | ||
@@ -129,0 +137,0 @@ |
| isexe:2.0.0 -- The ISC License | ||
| Copyright (c) Isaac Z. Schlueter and Contributors | ||
| Permission to use, copy, modify, and/or distribute this software for any | ||
| purpose with or without fee is hereby granted, provided that the above | ||
| copyright notice and this permission notice appear in all copies. | ||
| THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
| IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| which:2.0.2 -- The ISC License | ||
| Copyright (c) Isaac Z. Schlueter and Contributors | ||
| Permission to use, copy, modify, and/or distribute this software for any | ||
| purpose with or without fee is hereby granted, provided that the above | ||
| copyright notice and this permission notice appear in all copies. | ||
| THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
| IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| path-key:3.1.1 -- MIT License | ||
| Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| cross-spawn:7.0.6 -- The MIT License (MIT) | ||
| Copyright (c) 2018 Made With MOXY Lda <hello@moxy.studio> | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in | ||
| all copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| THE SOFTWARE. | ||
| shebang-regex:3.0.0 -- MIT License | ||
| Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| shebang-command:2.0.0 -- MIT License | ||
| Copyright (c) Kevin MĂĄrtensson <kevinmartensson@gmail.com> (github.com/kevva) | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Unidentified License
LicenseSomething that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
10
-23.08%0
-100%100
25%324
2.53%3
-72.73%22861
-35.29%5
-16.67%388
-43.11%1
Infinity%