| 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. |
| import { ChildProcess, SpawnOptions } from "node:child_process"; | ||
| import { Readable } from "node:stream"; | ||
| //#region src/non-zero-exit-error.d.ts | ||
| declare class NonZeroExitError extends Error { | ||
| readonly result: Result; | ||
| readonly output?: Output; | ||
| get exitCode(): number | undefined; | ||
| constructor(result: Result, output?: Output); | ||
| } | ||
| //#endregion | ||
| //#region src/main.d.ts | ||
| interface Output { | ||
| stderr: string; | ||
| stdout: string; | ||
| exitCode: number | undefined; | ||
| } | ||
| interface PipeOptions extends Options {} | ||
| type KillSignal = Parameters<ChildProcess['kill']>[0]; | ||
| interface OutputApi extends AsyncIterable<string> { | ||
| pipe(command: string, args?: string[], options?: Partial<PipeOptions>): Result; | ||
| process: ChildProcess | undefined; | ||
| kill(signal?: KillSignal): boolean; | ||
| get pid(): number | undefined; | ||
| get aborted(): boolean; | ||
| get killed(): boolean; | ||
| get exitCode(): number | undefined; | ||
| } | ||
| type Result = PromiseLike<Output> & OutputApi; | ||
| interface Options { | ||
| signal: AbortSignal; | ||
| nodeOptions: SpawnOptions; | ||
| timeout: number; | ||
| persist: boolean; | ||
| stdin: ExecProcess; | ||
| throwOnError: boolean; | ||
| } | ||
| interface TinyExec { | ||
| (command: string, args?: string[], options?: Partial<Options>): Result; | ||
| } | ||
| declare class ExecProcess implements Result { | ||
| protected _process?: ChildProcess; | ||
| protected _aborted: boolean; | ||
| protected _options: Partial<Options>; | ||
| protected _command: string; | ||
| protected _args: string[]; | ||
| protected _resolveClose?: () => void; | ||
| protected _processClosed: Promise<void>; | ||
| protected _thrownError?: Error; | ||
| get process(): ChildProcess | undefined; | ||
| get pid(): number | undefined; | ||
| get exitCode(): number | undefined; | ||
| constructor(command: string, args?: string[], options?: Partial<Options>); | ||
| kill(signal?: KillSignal): boolean; | ||
| get aborted(): boolean; | ||
| get killed(): boolean; | ||
| pipe(command: string, args?: string[], options?: Partial<PipeOptions>): Result; | ||
| [Symbol.asyncIterator](): AsyncIterator<string>; | ||
| protected _waitForOutput(): Promise<Output>; | ||
| then<TResult1 = Output, TResult2 = never>(onfulfilled?: ((value: Output) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>; | ||
| protected _streamOut?: Readable; | ||
| protected _streamErr?: Readable; | ||
| spawn(): void; | ||
| protected _resetState(): void; | ||
| protected _onError: (err: Error) => void; | ||
| protected _onClose: () => void; | ||
| } | ||
| declare const x: TinyExec; | ||
| declare const exec: TinyExec; | ||
| //#endregion | ||
| export { ExecProcess, KillSignal, NonZeroExitError, Options, Output, OutputApi, PipeOptions, Result, TinyExec, exec, x }; |
+642
| import { createRequire as e } from "node:module"; | ||
| import { spawn as t } from "node:child_process"; | ||
| import { delimiter as n, dirname as r, normalize as i, resolve as a } from "node:path"; | ||
| import { cwd as o } from "node:process"; | ||
| import { PassThrough as s } from "node:stream"; | ||
| import c from "node:readline"; | ||
| //#region \0rolldown/runtime.js | ||
| var l = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports); | ||
| var u = /* @__PURE__ */ e(import.meta.url); | ||
| //#endregion | ||
| //#region src/env.ts | ||
| const d = /^path$/i; | ||
| const f = { | ||
| key: "PATH", | ||
| value: "" | ||
| }; | ||
| function p(e) { | ||
| for (const t in e) { | ||
| if (!Object.prototype.hasOwnProperty.call(e, t) || !d.test(t)) continue; | ||
| const n = e[t]; | ||
| if (!n) return f; | ||
| return { | ||
| key: t, | ||
| value: n | ||
| }; | ||
| } | ||
| return f; | ||
| } | ||
| function m(e, t) { | ||
| const i = t.value.split(n); | ||
| const o = []; | ||
| let s = e; | ||
| let c; | ||
| do { | ||
| o.push(a(s, "node_modules", ".bin")); | ||
| c = s; | ||
| s = r(s); | ||
| } while (s !== c); | ||
| const l = o.concat(i).join(n); | ||
| return { | ||
| key: t.key, | ||
| value: l | ||
| }; | ||
| } | ||
| function h(e, t) { | ||
| const n = { | ||
| ...process.env, | ||
| ...t | ||
| }; | ||
| const r = m(e, p(n)); | ||
| n[r.key] = r.value; | ||
| return n; | ||
| } | ||
| //#endregion | ||
| //#region src/stream.ts | ||
| const g = (e) => { | ||
| let t = e.length; | ||
| const n = new s(); | ||
| const r = () => { | ||
| if (--t === 0) n.emit("end"); | ||
| }; | ||
| for (const t of e) { | ||
| t.pipe(n, { end: false }); | ||
| t.on("end", r); | ||
| } | ||
| return n; | ||
| }; | ||
| //#endregion | ||
| //#region node_modules/isexe/windows.js | ||
| var _ = /* @__PURE__ */ l(((e, t) => { | ||
| t.exports = a; | ||
| a.sync = o; | ||
| var n = u("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 v = /* @__PURE__ */ l(((e, t) => { | ||
| t.exports = r; | ||
| r.sync = i; | ||
| var n = u("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 y = /* @__PURE__ */ l(((e, t) => { | ||
| u("fs"); | ||
| var n; | ||
| if (process.platform === "win32" || global.TESTING_WINDOWS) n = _(); | ||
| else n = v(); | ||
| 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 b = /* @__PURE__ */ l(((e, t) => { | ||
| const n = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys"; | ||
| const r = u("path"); | ||
| const i = n ? ";" : ":"; | ||
| const a = y(); | ||
| 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 | ||
| }; | ||
| }; | ||
| 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 x = /* @__PURE__ */ l(((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 S = /* @__PURE__ */ l(((e, t) => { | ||
| const n = u("path"); | ||
| const r = b(); | ||
| const i = x(); | ||
| 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; | ||
| 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); | ||
| } | ||
| 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 C = /* @__PURE__ */ l(((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 w = /* @__PURE__ */ l(((e, t) => { | ||
| t.exports = /^#!(.*)/; | ||
| })); | ||
| //#endregion | ||
| //#region node_modules/shebang-command/index.js | ||
| var T = /* @__PURE__ */ l(((e, t) => { | ||
| const n = w(); | ||
| 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 E = /* @__PURE__ */ l(((e, t) => { | ||
| const n = u("fs"); | ||
| const r = T(); | ||
| 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 D = /* @__PURE__ */ l(((e, t) => { | ||
| const n = u("path"); | ||
| const r = S(); | ||
| const i = C(); | ||
| const a = E(); | ||
| 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); | ||
| } | ||
| return e.file; | ||
| } | ||
| function d(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; | ||
| } | ||
| 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 : d(r); | ||
| } | ||
| t.exports = f; | ||
| })); | ||
| //#endregion | ||
| //#region node_modules/cross-spawn/lib/enoent.js | ||
| var O = /* @__PURE__ */ l(((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 | ||
| }); | ||
| } | ||
| 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); | ||
| }; | ||
| } | ||
| 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 | ||
| }; | ||
| })); | ||
| //#endregion | ||
| //#region node_modules/cross-spawn/index.js | ||
| var k = /* @__PURE__ */ l(((e, t) => { | ||
| const n = u("child_process"); | ||
| const r = D(); | ||
| const i = O(); | ||
| 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; | ||
| } | ||
| 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; | ||
| })); | ||
| //#endregion | ||
| //#region src/non-zero-exit-error.ts | ||
| var A = k(); | ||
| var j = class extends Error { | ||
| result; | ||
| output; | ||
| get exitCode() { | ||
| if (this.result.exitCode !== null) return this.result.exitCode; | ||
| } | ||
| constructor(e, t) { | ||
| super(`Process exited with non-zero status (${e.exitCode})`); | ||
| this.result = e; | ||
| this.output = t; | ||
| } | ||
| }; | ||
| //#endregion | ||
| //#region src/main.ts | ||
| const M = { | ||
| timeout: void 0, | ||
| persist: false | ||
| }; | ||
| const N = { windowsHide: true }; | ||
| function P(e, t) { | ||
| return { | ||
| command: i(e), | ||
| args: t ?? [] | ||
| }; | ||
| } | ||
| function F(e) { | ||
| const t = new AbortController(); | ||
| for (const n of e) { | ||
| if (n.aborted) { | ||
| t.abort(); | ||
| return n; | ||
| } | ||
| const e = () => { | ||
| t.abort(n.reason); | ||
| }; | ||
| n.addEventListener("abort", e, { signal: t.signal }); | ||
| } | ||
| return t.signal; | ||
| } | ||
| async function I(e) { | ||
| let t = ""; | ||
| for await (const n of e) t += n.toString(); | ||
| return t; | ||
| } | ||
| var L = class { | ||
| _process; | ||
| _aborted = false; | ||
| _options; | ||
| _command; | ||
| _args; | ||
| _resolveClose; | ||
| _processClosed; | ||
| _thrownError; | ||
| get process() { | ||
| return this._process; | ||
| } | ||
| get pid() { | ||
| return this._process?.pid; | ||
| } | ||
| get exitCode() { | ||
| if (this._process && this._process.exitCode !== null) return this._process.exitCode; | ||
| } | ||
| constructor(e, t, n) { | ||
| this._options = { | ||
| ...M, | ||
| ...n | ||
| }; | ||
| this._command = e; | ||
| this._args = t ?? []; | ||
| this._processClosed = new Promise((e) => { | ||
| this._resolveClose = e; | ||
| }); | ||
| } | ||
| kill(e) { | ||
| return this._process?.kill(e) === true; | ||
| } | ||
| get aborted() { | ||
| return this._aborted; | ||
| } | ||
| get killed() { | ||
| return this._process?.killed === true; | ||
| } | ||
| pipe(e, t, n) { | ||
| return z(e, t, { | ||
| ...n, | ||
| stdin: this | ||
| }); | ||
| } | ||
| async *[Symbol.asyncIterator]() { | ||
| const e = this._process; | ||
| if (!e) return; | ||
| const t = []; | ||
| if (this._streamErr) t.push(this._streamErr); | ||
| if (this._streamOut) t.push(this._streamOut); | ||
| const n = g(t); | ||
| const r = c.createInterface({ input: n }); | ||
| for await (const e of r) yield e.toString(); | ||
| await this._processClosed; | ||
| e.removeAllListeners(); | ||
| if (this._thrownError) throw this._thrownError; | ||
| if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new j(this); | ||
| } | ||
| async _waitForOutput() { | ||
| const e = this._process; | ||
| if (!e) throw new Error("No process was started"); | ||
| const [t, n] = await Promise.all([this._streamOut ? I(this._streamOut) : "", this._streamErr ? I(this._streamErr) : ""]); | ||
| await this._processClosed; | ||
| if (this._options?.stdin) await this._options.stdin; | ||
| e.removeAllListeners(); | ||
| if (this._thrownError) throw this._thrownError; | ||
| const r = { | ||
| stderr: n, | ||
| stdout: t, | ||
| exitCode: this.exitCode | ||
| }; | ||
| if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new j(this, r); | ||
| return r; | ||
| } | ||
| then(e, t) { | ||
| return this._waitForOutput().then(e, t); | ||
| } | ||
| _streamOut; | ||
| _streamErr; | ||
| spawn() { | ||
| const e = o(); | ||
| const n = this._options; | ||
| const r = { | ||
| ...N, | ||
| ...n.nodeOptions | ||
| }; | ||
| const i = []; | ||
| this._resetState(); | ||
| if (n.timeout !== void 0) i.push(AbortSignal.timeout(n.timeout)); | ||
| if (n.signal !== void 0) i.push(n.signal); | ||
| if (n.persist === true) r.detached = true; | ||
| if (i.length > 0) r.signal = F(i); | ||
| r.env = h(e, r.env); | ||
| const { command: a, args: s } = P(this._command, this._args); | ||
| const c = (0, A._parse)(a, s, r); | ||
| const l = t(c.command, c.args, c.options); | ||
| if (l.stderr) this._streamErr = l.stderr; | ||
| if (l.stdout) this._streamOut = l.stdout; | ||
| this._process = l; | ||
| l.once("error", this._onError); | ||
| l.once("close", this._onClose); | ||
| if (n.stdin !== void 0 && l.stdin && n.stdin.process) { | ||
| const { stdout: e } = n.stdin.process; | ||
| if (e) e.pipe(l.stdin); | ||
| } | ||
| } | ||
| _resetState() { | ||
| this._aborted = false; | ||
| this._processClosed = new Promise((e) => { | ||
| this._resolveClose = e; | ||
| }); | ||
| this._thrownError = void 0; | ||
| } | ||
| _onError = (e) => { | ||
| if (e.name === "AbortError" && (!(e.cause instanceof Error) || e.cause.name !== "TimeoutError")) { | ||
| this._aborted = true; | ||
| return; | ||
| } | ||
| this._thrownError = e; | ||
| }; | ||
| _onClose = () => { | ||
| if (this._resolveClose) this._resolveClose(); | ||
| }; | ||
| }; | ||
| const R = (e, t, n) => { | ||
| const r = new L(e, t, n); | ||
| r.spawn(); | ||
| return r; | ||
| }; | ||
| const z = R; | ||
| //#endregion | ||
| export { L as ExecProcess, j as NonZeroExitError, z as exec, R as x }; |
+11
-10
| { | ||
| "name": "tinyexec", | ||
| "version": "1.0.2", | ||
| "version": "1.0.3", | ||
| "type": "module", | ||
@@ -41,12 +41,13 @@ "description": "A minimal library for executing processes in Node", | ||
| "devDependencies": { | ||
| "@eslint/js": "^9.0.0", | ||
| "@eslint/js": "^10.0.1", | ||
| "@types/cross-spawn": "^6.0.6", | ||
| "@types/node": "^20.12.7", | ||
| "@vitest/coverage-v8": "^4.0.7", | ||
| "cross-spawn": "^7.0.3", | ||
| "eslint-config-google": "^0.14.0", | ||
| "prettier": "^3.2.5", | ||
| "tsdown": "^0.9.9", | ||
| "typescript": "^5.4.5", | ||
| "typescript-eslint": "^7.7.0", | ||
| "@types/node": "^25.4.0", | ||
| "@vitest/coverage-v8": "^4.0.18", | ||
| "cross-spawn": "^7.0.6", | ||
| "eslint": "^10.0.3", | ||
| "prettier": "^3.8.1", | ||
| "rollup-plugin-license": "^3.7.0", | ||
| "tsdown": "^0.21.1", | ||
| "typescript": "^5.9.3", | ||
| "typescript-eslint": "^8.57.0", | ||
| "vitest": "^4.0.7" | ||
@@ -53,0 +54,0 @@ }, |
| /// <reference types="node" resolution-mode="require"/> | ||
| import { ChildProcess, SpawnOptions } from "node:child_process"; | ||
| import { Readable } from "node:stream"; | ||
| //#region src/non-zero-exit-error.d.ts | ||
| declare class NonZeroExitError extends Error { | ||
| readonly result: Result; | ||
| readonly output?: Output; | ||
| get exitCode(): number | undefined; | ||
| constructor(result: Result, output?: Output); | ||
| } | ||
| //#endregion | ||
| //#region src/main.d.ts | ||
| interface Output { | ||
| stderr: string; | ||
| stdout: string; | ||
| exitCode: number | undefined; | ||
| } | ||
| interface PipeOptions extends Options {} | ||
| type KillSignal = Parameters<ChildProcess['kill']>[0]; | ||
| interface OutputApi extends AsyncIterable<string> { | ||
| pipe(command: string, args?: string[], options?: Partial<PipeOptions>): Result; | ||
| process: ChildProcess | undefined; | ||
| kill(signal?: KillSignal): boolean; | ||
| get pid(): number | undefined; | ||
| get aborted(): boolean; | ||
| get killed(): boolean; | ||
| get exitCode(): number | undefined; | ||
| } | ||
| type Result = PromiseLike<Output> & OutputApi; | ||
| interface Options { | ||
| signal: AbortSignal; | ||
| nodeOptions: SpawnOptions; | ||
| timeout: number; | ||
| persist: boolean; | ||
| stdin: ExecProcess; | ||
| throwOnError: boolean; | ||
| } | ||
| interface TinyExec { | ||
| (command: string, args?: string[], options?: Partial<Options>): Result; | ||
| } | ||
| declare class ExecProcess implements Result { | ||
| protected _process?: ChildProcess; | ||
| protected _aborted: boolean; | ||
| protected _options: Partial<Options>; | ||
| protected _command: string; | ||
| protected _args: string[]; | ||
| protected _resolveClose?: () => void; | ||
| protected _processClosed: Promise<void>; | ||
| protected _thrownError?: Error; | ||
| get process(): ChildProcess | undefined; | ||
| get pid(): number | undefined; | ||
| get exitCode(): number | undefined; | ||
| constructor(command: string, args?: string[], options?: Partial<Options>); | ||
| kill(signal?: KillSignal): boolean; | ||
| get aborted(): boolean; | ||
| get killed(): boolean; | ||
| pipe(command: string, args?: string[], options?: Partial<PipeOptions>): Result; | ||
| [Symbol.asyncIterator](): AsyncIterator<string>; | ||
| protected _waitForOutput(): Promise<Output>; | ||
| then<TResult1 = Output, TResult2 = never>(onfulfilled?: ((value: Output) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>; | ||
| protected _streamOut?: Readable; | ||
| protected _streamErr?: Readable; | ||
| spawn(): void; | ||
| protected _resetState(): void; | ||
| protected _onError: (err: Error) => void; | ||
| protected _onClose: () => void; | ||
| } | ||
| declare const x: TinyExec; | ||
| declare const exec: TinyExec; | ||
| //#endregion | ||
| export { ExecProcess, KillSignal, NonZeroExitError, Options, Output, OutputApi, PipeOptions, Result, TinyExec, exec, x }; |
-633
| import { createRequire as e } from "module"; | ||
| import { spawn as t } from "node:child_process"; | ||
| import { delimiter as n, dirname as r, normalize as i, resolve as a } from "node:path"; | ||
| import { cwd as o } from "node:process"; | ||
| import { PassThrough as s } from "node:stream"; | ||
| import c from "node:readline"; | ||
| var l = Object.create; | ||
| var u = Object.defineProperty; | ||
| var d = Object.getOwnPropertyDescriptor; | ||
| var f = Object.getOwnPropertyNames; | ||
| var p = Object.getPrototypeOf; | ||
| var m = Object.prototype.hasOwnProperty; | ||
| var h = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports); | ||
| var g = (e, t, n, r) => { | ||
| if (t && typeof t === "object" || typeof t === "function") for (var i = f(t), a = 0, o = i.length, s; a < o; a++) { | ||
| s = i[a]; | ||
| if (!m.call(e, s) && s !== n) u(e, s, { | ||
| get: ((e) => t[e]).bind(null, s), | ||
| enumerable: !(r = d(t, s)) || r.enumerable | ||
| }); | ||
| } | ||
| return e; | ||
| }; | ||
| var _ = (e, t, n) => (n = e != null ? l(p(e)) : {}, g(t || !e || !e.__esModule ? u(n, "default", { | ||
| value: e, | ||
| enumerable: true | ||
| }) : n, e)); | ||
| var v = /* @__PURE__ */ e(import.meta.url); | ||
| const y = /^path$/i; | ||
| const b = { | ||
| key: "PATH", | ||
| value: "" | ||
| }; | ||
| function x(e) { | ||
| for (const t in e) { | ||
| if (!Object.prototype.hasOwnProperty.call(e, t) || !y.test(t)) continue; | ||
| const n = e[t]; | ||
| if (!n) return b; | ||
| return { | ||
| key: t, | ||
| value: n | ||
| }; | ||
| } | ||
| return b; | ||
| } | ||
| function S(e, t) { | ||
| const i = t.value.split(n); | ||
| let o = e; | ||
| let s; | ||
| do { | ||
| i.push(a(o, "node_modules", ".bin")); | ||
| s = o; | ||
| o = r(o); | ||
| } while (o !== s); | ||
| return { | ||
| key: t.key, | ||
| value: i.join(n) | ||
| }; | ||
| } | ||
| function C(e, t) { | ||
| const n = { | ||
| ...process.env, | ||
| ...t | ||
| }; | ||
| const r = S(e, x(n)); | ||
| n[r.key] = r.value; | ||
| return n; | ||
| } | ||
| const w = (e) => { | ||
| let t = e.length; | ||
| const n = new s(); | ||
| const r = () => { | ||
| if (--t === 0) n.emit("end"); | ||
| }; | ||
| for (const t of e) { | ||
| t.pipe(n, { end: false }); | ||
| t.on("end", r); | ||
| } | ||
| return n; | ||
| }; | ||
| var T = h((exports, t) => { | ||
| t.exports = a; | ||
| a.sync = o; | ||
| var n = v("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); | ||
| } | ||
| }); | ||
| var E = h((exports, t) => { | ||
| t.exports = r; | ||
| r.sync = i; | ||
| var n = v("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; | ||
| var d = n & l || n & c && i === o || n & s && r === a || n & u && a === 0; | ||
| return d; | ||
| } | ||
| }); | ||
| var D = h((exports, t) => { | ||
| var n = v("fs"); | ||
| var r; | ||
| if (process.platform === "win32" || global.TESTING_WINDOWS) r = T(); | ||
| else r = E(); | ||
| t.exports = i; | ||
| i.sync = a; | ||
| function i(e, t, n) { | ||
| if (typeof t === "function") { | ||
| n = t; | ||
| t = {}; | ||
| } | ||
| if (!n) { | ||
| if (typeof Promise !== "function") throw new TypeError("callback not provided"); | ||
| return new Promise(function(n, r) { | ||
| i(e, t || {}, function(e, t) { | ||
| if (e) r(e); | ||
| else n(t); | ||
| }); | ||
| }); | ||
| } | ||
| r(e, t || {}, function(e, r) { | ||
| if (e) { | ||
| if (e.code === "EACCES" || t && t.ignoreErrors) { | ||
| e = null; | ||
| r = false; | ||
| } | ||
| } | ||
| n(e, r); | ||
| }); | ||
| } | ||
| function a(e, t) { | ||
| try { | ||
| return r.sync(e, t || {}); | ||
| } catch (e) { | ||
| if (t && t.ignoreErrors || e.code === "EACCES") return false; | ||
| else throw e; | ||
| } | ||
| } | ||
| }); | ||
| var O = h((exports, t) => { | ||
| const n = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys"; | ||
| const r = v("path"); | ||
| const i = n ? ";" : ":"; | ||
| const a = D(); | ||
| const o = (e) => Object.assign(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 | ||
| }; | ||
| }; | ||
| 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); | ||
| const p = !l && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d; | ||
| a(f(p, 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 { | ||
| const e = a.sync(n, { pathExt: c }); | ||
| if (e) 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; | ||
| }); | ||
| var k = h((exports, t) => { | ||
| const n = (e = {}) => { | ||
| const t = e.env || process.env; | ||
| const n = e.platform || process.platform; | ||
| if (n !== "win32") return "PATH"; | ||
| return Object.keys(t).reverse().find((e) => e.toUpperCase() === "PATH") || "Path"; | ||
| }; | ||
| t.exports = n; | ||
| t.exports.default = n; | ||
| }); | ||
| var A = h((exports, t) => { | ||
| const n = v("path"); | ||
| const r = O(); | ||
| const i = k(); | ||
| 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; | ||
| 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); | ||
| } | ||
| if (l) l = n.resolve(s ? e.options.cwd : "", l); | ||
| return l; | ||
| } | ||
| function o(e) { | ||
| return a(e) || a(e, true); | ||
| } | ||
| t.exports = o; | ||
| }); | ||
| var j = h((exports, t) => { | ||
| const n = /([()\][%!^"`<>&|;, *?])/g; | ||
| function r(e) { | ||
| e = e.replace(n, "^$1"); | ||
| return e; | ||
| } | ||
| function i(e, t) { | ||
| e = `${e}`; | ||
| e = e.replace(/(\\*)"/g, "$1$1\\\""); | ||
| e = e.replace(/(\\*)$/, "$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; | ||
| }); | ||
| var M = h((exports, t) => { | ||
| t.exports = /^#!(.*)/; | ||
| }); | ||
| var N = h((exports, t) => { | ||
| const n = M(); | ||
| 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; | ||
| }; | ||
| }); | ||
| var P = h((exports, t) => { | ||
| const n = v("fs"); | ||
| const r = N(); | ||
| 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; | ||
| }); | ||
| var F = h((exports, t) => { | ||
| const n = v("path"); | ||
| const r = A(); | ||
| const i = j(); | ||
| const a = P(); | ||
| 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); | ||
| } | ||
| 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)); | ||
| const a = [e.command].concat(e.args).join(" "); | ||
| e.args = [ | ||
| "/d", | ||
| "/s", | ||
| "/c", | ||
| `"${a}"` | ||
| ]; | ||
| e.command = process.env.comspec || "cmd.exe"; | ||
| e.options.windowsVerbatimArguments = true; | ||
| } | ||
| return e; | ||
| } | ||
| function d(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 = d; | ||
| }); | ||
| var I = h((exports, t) => { | ||
| const n = process.platform === "win32"; | ||
| function r(e, t) { | ||
| return Object.assign(new Error(`${t} ${e.command} ENOENT`), { | ||
| code: "ENOENT", | ||
| errno: "ENOENT", | ||
| syscall: `${t} ${e.command}`, | ||
| path: e.command, | ||
| spawnargs: e.args | ||
| }); | ||
| } | ||
| function i(e, t) { | ||
| if (!n) return; | ||
| const r = e.emit; | ||
| e.emit = function(n, i) { | ||
| if (n === "exit") { | ||
| const n = a(i, t, "spawn"); | ||
| if (n) return r.call(e, "error", n); | ||
| } | ||
| return r.apply(e, arguments); | ||
| }; | ||
| } | ||
| 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 | ||
| }; | ||
| }); | ||
| var L = h((exports, t) => { | ||
| const n = v("child_process"); | ||
| const r = F(); | ||
| const i = I(); | ||
| 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; | ||
| } | ||
| 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; | ||
| }); | ||
| var R = _(L(), 1); | ||
| var z = class extends Error { | ||
| result; | ||
| output; | ||
| get exitCode() { | ||
| if (this.result.exitCode !== null) return this.result.exitCode; | ||
| return void 0; | ||
| } | ||
| constructor(e, t) { | ||
| super(`Process exited with non-zero status (${e.exitCode})`); | ||
| this.result = e; | ||
| this.output = t; | ||
| } | ||
| }; | ||
| const B = { | ||
| timeout: void 0, | ||
| persist: false | ||
| }; | ||
| const V = { windowsHide: true }; | ||
| function H(e, t) { | ||
| const n = i(e); | ||
| const r = t ?? []; | ||
| return { | ||
| command: n, | ||
| args: r | ||
| }; | ||
| } | ||
| function U(e) { | ||
| const t = new AbortController(); | ||
| for (const n of e) { | ||
| if (n.aborted) { | ||
| t.abort(); | ||
| return n; | ||
| } | ||
| const e = () => { | ||
| t.abort(n.reason); | ||
| }; | ||
| n.addEventListener("abort", e, { signal: t.signal }); | ||
| } | ||
| return t.signal; | ||
| } | ||
| async function W(e) { | ||
| let t = ""; | ||
| for await (const n of e) t += n.toString(); | ||
| return t; | ||
| } | ||
| var G = class { | ||
| _process; | ||
| _aborted = false; | ||
| _options; | ||
| _command; | ||
| _args; | ||
| _resolveClose; | ||
| _processClosed; | ||
| _thrownError; | ||
| get process() { | ||
| return this._process; | ||
| } | ||
| get pid() { | ||
| return this._process?.pid; | ||
| } | ||
| get exitCode() { | ||
| if (this._process && this._process.exitCode !== null) return this._process.exitCode; | ||
| return void 0; | ||
| } | ||
| constructor(e, t, n) { | ||
| this._options = { | ||
| ...B, | ||
| ...n | ||
| }; | ||
| this._command = e; | ||
| this._args = t ?? []; | ||
| this._processClosed = new Promise((e) => { | ||
| this._resolveClose = e; | ||
| }); | ||
| } | ||
| kill(e) { | ||
| return this._process?.kill(e) === true; | ||
| } | ||
| get aborted() { | ||
| return this._aborted; | ||
| } | ||
| get killed() { | ||
| return this._process?.killed === true; | ||
| } | ||
| pipe(e, t, n) { | ||
| return q(e, t, { | ||
| ...n, | ||
| stdin: this | ||
| }); | ||
| } | ||
| async *[Symbol.asyncIterator]() { | ||
| const e = this._process; | ||
| if (!e) return; | ||
| const t = []; | ||
| if (this._streamErr) t.push(this._streamErr); | ||
| if (this._streamOut) t.push(this._streamOut); | ||
| const n = w(t); | ||
| const r = c.createInterface({ input: n }); | ||
| for await (const e of r) yield e.toString(); | ||
| await this._processClosed; | ||
| e.removeAllListeners(); | ||
| if (this._thrownError) throw this._thrownError; | ||
| if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new z(this); | ||
| } | ||
| async _waitForOutput() { | ||
| const e = this._process; | ||
| if (!e) throw new Error("No process was started"); | ||
| const [t, n] = await Promise.all([this._streamOut ? W(this._streamOut) : "", this._streamErr ? W(this._streamErr) : ""]); | ||
| await this._processClosed; | ||
| if (this._options?.stdin) await this._options.stdin; | ||
| e.removeAllListeners(); | ||
| if (this._thrownError) throw this._thrownError; | ||
| const r = { | ||
| stderr: n, | ||
| stdout: t, | ||
| exitCode: this.exitCode | ||
| }; | ||
| if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new z(this, r); | ||
| return r; | ||
| } | ||
| then(e, t) { | ||
| return this._waitForOutput().then(e, t); | ||
| } | ||
| _streamOut; | ||
| _streamErr; | ||
| spawn() { | ||
| const e = o(); | ||
| const n = this._options; | ||
| const r = { | ||
| ...V, | ||
| ...n.nodeOptions | ||
| }; | ||
| const i = []; | ||
| this._resetState(); | ||
| if (n.timeout !== void 0) i.push(AbortSignal.timeout(n.timeout)); | ||
| if (n.signal !== void 0) i.push(n.signal); | ||
| if (n.persist === true) r.detached = true; | ||
| if (i.length > 0) r.signal = U(i); | ||
| r.env = C(e, r.env); | ||
| const { command: a, args: s } = H(this._command, this._args); | ||
| const c = (0, R._parse)(a, s, r); | ||
| const l = t(c.command, c.args, c.options); | ||
| if (l.stderr) this._streamErr = l.stderr; | ||
| if (l.stdout) this._streamOut = l.stdout; | ||
| this._process = l; | ||
| l.once("error", this._onError); | ||
| l.once("close", this._onClose); | ||
| if (n.stdin !== void 0 && l.stdin && n.stdin.process) { | ||
| const { stdout: e } = n.stdin.process; | ||
| if (e) e.pipe(l.stdin); | ||
| } | ||
| } | ||
| _resetState() { | ||
| this._aborted = false; | ||
| this._processClosed = new Promise((e) => { | ||
| this._resolveClose = e; | ||
| }); | ||
| this._thrownError = void 0; | ||
| } | ||
| _onError = (e) => { | ||
| if (e.name === "AbortError" && (!(e.cause instanceof Error) || e.cause.name !== "TimeoutError")) { | ||
| this._aborted = true; | ||
| return; | ||
| } | ||
| this._thrownError = e; | ||
| }; | ||
| _onClose = () => { | ||
| if (this._resolveClose) this._resolveClose(); | ||
| }; | ||
| }; | ||
| const K = (e, t, n) => { | ||
| const r = new G(e, t, n); | ||
| r.spawn(); | ||
| return r; | ||
| }; | ||
| const q = K; | ||
| export { G as ExecProcess, z as NonZeroExitError, q as exec, K as x }; |
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 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
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
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
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
32589
24.79%6
20%11
-8.33%12
9.09%1
Infinity%80
-20%642
-8.68%