+6
-6
@@ -28,3 +28,3 @@ import { ChildProcess, SpawnOptions, SpawnSyncOptions } from "node:child_process"; | ||
| get aborted(): boolean; | ||
| pipe(command: string, args?: string[], options?: Partial<PipeOptions>): Result; | ||
| pipe(command: string, args?: readonly string[], options?: Partial<PipeOptions>): Result; | ||
| kill(signal?: KillSignal): boolean; | ||
@@ -49,3 +49,3 @@ } | ||
| interface TinyExec { | ||
| (command: string, args?: string[], options?: Partial<Options>): Result; | ||
| (command: string, args?: readonly string[], options?: Partial<Options>): Result; | ||
| } | ||
@@ -57,3 +57,3 @@ declare class ExecProcess implements Result { | ||
| protected _command: string; | ||
| protected _args: string[]; | ||
| protected _args: readonly string[]; | ||
| protected _resolveClose?: () => void; | ||
@@ -65,7 +65,7 @@ protected _processClosed: Promise<void>; | ||
| get exitCode(): number | undefined; | ||
| constructor(command: string, args?: string[], options?: Partial<Options>); | ||
| constructor(command: string, args?: readonly string[], options?: Partial<Options>); | ||
| kill(signal?: KillSignal): boolean; | ||
| get aborted(): boolean; | ||
| get killed(): boolean; | ||
| pipe(command: string, args?: string[], options?: Partial<PipeOptions>): Result; | ||
| pipe(command: string, args?: readonly string[], options?: Partial<PipeOptions>): Result; | ||
| [Symbol.asyncIterator](): AsyncIterator<string>; | ||
@@ -81,3 +81,3 @@ protected _waitForOutput(): Promise<Output>; | ||
| } | ||
| declare function xSync(command: string, args?: string[], options?: Partial<SyncOptions>): SyncResult; | ||
| declare function xSync(command: string, args?: readonly string[], options?: Partial<SyncOptions>): SyncResult; | ||
| declare const x: TinyExec; | ||
@@ -84,0 +84,0 @@ declare const exec: TinyExec; |
+126
-134
| import { createRequire as e } from "node:module"; | ||
| import { spawn as t, spawnSync as n } from "node:child_process"; | ||
| import { delimiter as r, dirname as i, normalize as a, resolve as o } from "node:path"; | ||
| import { cwd as s } from "node:process"; | ||
| import { pipeline as c } from "node:stream/promises"; | ||
| import { PassThrough as l } from "node:stream"; | ||
| import u from "node:readline"; | ||
| 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 d = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports); | ||
| var f = /* @__PURE__ */ e(import.meta.url); | ||
| var u = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports); | ||
| var d = /* @__PURE__ */ e(import.meta.url); | ||
| //#endregion | ||
| //#region src/env.ts | ||
| const p = /^path$/i; | ||
| const m = { | ||
| const f = /^path$/i; | ||
| const p = { | ||
| key: "PATH", | ||
| value: "" | ||
| }; | ||
| function h(e) { | ||
| function m(e) { | ||
| for (const t in e) { | ||
| if (!Object.prototype.hasOwnProperty.call(e, t) || !p.test(t)) continue; | ||
| if (!Object.prototype.hasOwnProperty.call(e, t) || !f.test(t)) continue; | ||
| const n = e[t]; | ||
| if (!n) return m; | ||
| if (!n) return p; | ||
| return { | ||
@@ -28,16 +28,16 @@ key: t, | ||
| } | ||
| return m; | ||
| return p; | ||
| } | ||
| function g(e, t) { | ||
| const n = t.value.split(r); | ||
| const a = []; | ||
| function h(e, t) { | ||
| const n = t.value.split(i); | ||
| const r = []; | ||
| let s = e; | ||
| let c; | ||
| do { | ||
| a.push(o(s, "node_modules", ".bin")); | ||
| r.push(o(s, "node_modules", ".bin")); | ||
| c = s; | ||
| s = i(s); | ||
| s = a(s); | ||
| } while (s !== c); | ||
| a.push(i(process.execPath)); | ||
| const l = a.concat(n).join(r); | ||
| r.push(a(process.execPath)); | ||
| const l = r.concat(n).join(i); | ||
| return { | ||
@@ -48,3 +48,3 @@ key: t.key, | ||
| } | ||
| function _(e, t) { | ||
| function g(e, t) { | ||
| const n = { | ||
@@ -54,3 +54,3 @@ ...process.env, | ||
| }; | ||
| const r = g(e, h(n)); | ||
| const r = h(e, m(n)); | ||
| n[r.key] = r.value; | ||
@@ -61,9 +61,9 @@ return n; | ||
| //#region src/stream.ts | ||
| const v = (e) => { | ||
| const _ = (e) => { | ||
| let t = e.length; | ||
| const n = new l(); | ||
| const n = new c(); | ||
| const r = () => { | ||
| if (--t === 0) n.end(); | ||
| }; | ||
| for (const t of e) c(t, n, { end: false }).then(r).catch(r); | ||
| for (const t of e) s(t, n, { end: false }).then(r).catch(r); | ||
| return n; | ||
@@ -73,6 +73,6 @@ }; | ||
| //#region node_modules/isexe/windows.js | ||
| var y = /* @__PURE__ */ d(((e, t) => { | ||
| var v = /* @__PURE__ */ u(((e, t) => { | ||
| t.exports = a; | ||
| a.sync = o; | ||
| var n = f("fs"); | ||
| var n = d("fs"); | ||
| function r(e, t) { | ||
@@ -104,6 +104,6 @@ var n = t.pathExt !== void 0 ? t.pathExt : process.env.PATHEXT; | ||
| //#region node_modules/isexe/mode.js | ||
| var b = /* @__PURE__ */ d(((e, t) => { | ||
| var y = /* @__PURE__ */ u(((e, t) => { | ||
| t.exports = r; | ||
| r.sync = i; | ||
| var n = f("fs"); | ||
| var n = d("fs"); | ||
| function r(e, t, r) { | ||
@@ -135,7 +135,7 @@ n.stat(e, function(e, n) { | ||
| //#region node_modules/isexe/index.js | ||
| var x = /* @__PURE__ */ d(((e, t) => { | ||
| f("fs"); | ||
| var b = /* @__PURE__ */ u(((e, t) => { | ||
| d("fs"); | ||
| var n; | ||
| if (process.platform === "win32" || global.TESTING_WINDOWS) n = y(); | ||
| else n = b(); | ||
| if (process.platform === "win32" || global.TESTING_WINDOWS) n = v(); | ||
| else n = y(); | ||
| t.exports = r; | ||
@@ -178,7 +178,7 @@ r.sync = i; | ||
| //#region node_modules/which/which.js | ||
| var S = /* @__PURE__ */ d(((e, t) => { | ||
| var x = /* @__PURE__ */ u(((e, t) => { | ||
| const n = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys"; | ||
| const r = f("path"); | ||
| const r = d("path"); | ||
| const i = n ? ";" : ":"; | ||
| const a = x(); | ||
| const a = b(); | ||
| const o = (e) => Object.assign(/* @__PURE__ */ new Error(`not found: ${e}`), { code: "ENOENT" }); | ||
@@ -251,3 +251,3 @@ const s = (e, t) => { | ||
| //#region node_modules/path-key/index.js | ||
| var C = /* @__PURE__ */ d(((e, t) => { | ||
| var S = /* @__PURE__ */ u(((e, t) => { | ||
| const n = (e = {}) => { | ||
@@ -263,6 +263,6 @@ const t = e.env || process.env; | ||
| //#region node_modules/cross-spawn/lib/util/resolveCommand.js | ||
| var w = /* @__PURE__ */ d(((e, t) => { | ||
| const n = f("path"); | ||
| const r = S(); | ||
| const i = C(); | ||
| var C = /* @__PURE__ */ u(((e, t) => { | ||
| const n = d("path"); | ||
| const r = x(); | ||
| const i = S(); | ||
| function a(e, t) { | ||
@@ -295,3 +295,3 @@ const a = e.options.env || process.env; | ||
| //#region node_modules/cross-spawn/lib/util/escape.js | ||
| var T = /* @__PURE__ */ d(((e, t) => { | ||
| var w = /* @__PURE__ */ u(((e, t) => { | ||
| const n = /([()\][%!^"`<>&|;, *?])/g; | ||
@@ -316,3 +316,3 @@ function r(e) { | ||
| //#region node_modules/shebang-regex/index.js | ||
| var E = /* @__PURE__ */ d(((e, t) => { | ||
| var T = /* @__PURE__ */ u(((e, t) => { | ||
| t.exports = /^#!(.*)/; | ||
@@ -322,4 +322,4 @@ })); | ||
| //#region node_modules/shebang-command/index.js | ||
| var D = /* @__PURE__ */ d(((e, t) => { | ||
| const n = E(); | ||
| var E = /* @__PURE__ */ u(((e, t) => { | ||
| const n = T(); | ||
| t.exports = (e = "") => { | ||
@@ -336,5 +336,5 @@ const t = e.match(n); | ||
| //#region node_modules/cross-spawn/lib/util/readShebang.js | ||
| var O = /* @__PURE__ */ d(((e, t) => { | ||
| const n = f("fs"); | ||
| const r = D(); | ||
| var D = /* @__PURE__ */ u(((e, t) => { | ||
| const n = d("fs"); | ||
| const r = E(); | ||
| function i(e) { | ||
@@ -355,7 +355,7 @@ const t = 150; | ||
| //#region node_modules/cross-spawn/lib/parse.js | ||
| var k = /* @__PURE__ */ d(((e, t) => { | ||
| const n = f("path"); | ||
| const r = w(); | ||
| const i = T(); | ||
| const a = O(); | ||
| var O = /* @__PURE__ */ u(((e, t) => { | ||
| const n = d("path"); | ||
| const r = C(); | ||
| const i = w(); | ||
| const a = D(); | ||
| const o = process.platform === "win32"; | ||
@@ -394,3 +394,3 @@ const s = /\.(?:com|exe)$/i; | ||
| } | ||
| function d(e, t, n) { | ||
| function f(e, t, n) { | ||
| if (t && !Array.isArray(t)) { | ||
@@ -414,7 +414,7 @@ n = t; | ||
| } | ||
| t.exports = d; | ||
| t.exports = f; | ||
| })); | ||
| //#endregion | ||
| //#region node_modules/cross-spawn/lib/enoent.js | ||
| var A = /* @__PURE__ */ d(((e, t) => { | ||
| var k = /* @__PURE__ */ u(((e, t) => { | ||
| const n = process.platform === "win32"; | ||
@@ -458,6 +458,6 @@ function r(e, t) { | ||
| //#region node_modules/cross-spawn/index.js | ||
| var j = /* @__PURE__ */ d(((e, t) => { | ||
| const n = f("child_process"); | ||
| const r = k(); | ||
| const i = A(); | ||
| var A = /* @__PURE__ */ u(((e, t) => { | ||
| const n = d("child_process"); | ||
| const r = O(); | ||
| const i = k(); | ||
| function a(e, t, a) { | ||
@@ -483,4 +483,4 @@ const o = r(e, t, a); | ||
| //#region src/non-zero-exit-error.ts | ||
| var M = j(); | ||
| var N = class extends Error { | ||
| var j = A(); | ||
| var M = class extends Error { | ||
| get exitCode() { | ||
@@ -497,16 +497,10 @@ if (this.result.exitCode !== null) return this.result.exitCode; | ||
| //#region src/main.ts | ||
| const P = /\r?\n/; | ||
| const F = { | ||
| const N = /\r?\n/; | ||
| const P = { | ||
| timeout: void 0, | ||
| persist: false | ||
| }; | ||
| const I = { timeout: void 0 }; | ||
| const L = { windowsHide: true }; | ||
| function R(e, t) { | ||
| return { | ||
| command: a(e), | ||
| args: t ?? [] | ||
| }; | ||
| } | ||
| function z(e) { | ||
| const F = { timeout: void 0 }; | ||
| const I = { windowsHide: true }; | ||
| function L(e) { | ||
| const t = new AbortController(); | ||
@@ -525,3 +519,3 @@ for (const n of e) { | ||
| } | ||
| async function B(e) { | ||
| async function R(e) { | ||
| let t = ""; | ||
@@ -533,3 +527,3 @@ try { | ||
| } | ||
| var V = class { | ||
| var z = class { | ||
| _process; | ||
@@ -554,3 +548,3 @@ _aborted = false; | ||
| this._options = { | ||
| ...F, | ||
| ...P, | ||
| ...n | ||
@@ -574,3 +568,3 @@ }; | ||
| pipe(e, t, n) { | ||
| return W(e, t, { | ||
| return H(e, t, { | ||
| ...n, | ||
@@ -586,4 +580,4 @@ stdin: this | ||
| if (this._streamOut) t.push(this._streamOut); | ||
| const n = v(t); | ||
| const r = u.createInterface({ input: n }); | ||
| const n = _(t); | ||
| const r = l.createInterface({ input: n }); | ||
| for await (const e of r) yield e.toString(); | ||
@@ -593,3 +587,3 @@ await this._processClosed; | ||
| if (this._thrownError) throw this._thrownError; | ||
| if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new N(this); | ||
| if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new M(this); | ||
| } | ||
@@ -599,3 +593,3 @@ async _waitForOutput() { | ||
| if (!e) throw new Error("No process was started"); | ||
| const [t, n] = await Promise.all([this._streamOut ? B(this._streamOut) : "", this._streamErr ? B(this._streamErr) : ""]); | ||
| const [t, n] = await Promise.all([this._streamOut ? R(this._streamOut) : "", this._streamErr ? R(this._streamErr) : ""]); | ||
| await this._processClosed; | ||
@@ -611,3 +605,3 @@ const { stdin: r } = this._options; | ||
| }; | ||
| if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new N(this, i); | ||
| if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new M(this, i); | ||
| return i; | ||
@@ -621,27 +615,26 @@ } | ||
| spawn() { | ||
| const e = s(); | ||
| const e = r(); | ||
| const n = this._options; | ||
| const r = { | ||
| ...L, | ||
| const i = { | ||
| ...I, | ||
| ...n.nodeOptions | ||
| }; | ||
| const i = []; | ||
| const a = []; | ||
| 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 = z(i); | ||
| r.env = _(e, r.env); | ||
| const { command: a, args: o } = R(this._command, this._args); | ||
| const c = (0, M._parse)(a, o, 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 (l.stdin) { | ||
| 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 (s.stderr) this._streamErr = s.stderr; | ||
| if (s.stdout) this._streamOut = s.stdout; | ||
| this._process = s; | ||
| s.once("error", this._onError); | ||
| s.once("close", this._onClose); | ||
| if (s.stdin) { | ||
| const { stdin: e } = n; | ||
| if (typeof e === "string") l.stdin.end(e); | ||
| else e?.process?.stdout?.pipe(l.stdin); | ||
| if (typeof e === "string") s.stdin.end(e); | ||
| else e?.process?.stdout?.pipe(s.stdin); | ||
| } | ||
@@ -667,38 +660,37 @@ } | ||
| }; | ||
| function H(e, t, r) { | ||
| const i = { | ||
| ...I, | ||
| ...r | ||
| function B(e, t, i) { | ||
| const a = { | ||
| ...F, | ||
| ...i | ||
| }; | ||
| const a = s(); | ||
| const o = { | ||
| const o = r(); | ||
| const s = { | ||
| windowsHide: true, | ||
| ...i.nodeOptions | ||
| ...a.nodeOptions | ||
| }; | ||
| if (i.timeout !== void 0) o.timeout = i.timeout; | ||
| o.env = _(a, o.env); | ||
| const { command: c, args: l } = R(e, t); | ||
| const u = (0, M._parse)(c, l, o); | ||
| const d = n(u.command, u.args, u.options); | ||
| if (d.error) throw d.error; | ||
| const f = d.stdout?.toString() ?? ""; | ||
| const p = d.stderr?.toString() ?? ""; | ||
| const m = d.status ?? void 0; | ||
| const h = d.signal != null; | ||
| const g = { | ||
| stdout: f, | ||
| stderr: p, | ||
| 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); | ||
| if (l.error) throw l.error; | ||
| const u = l.stdout?.toString() ?? ""; | ||
| const d = l.stderr?.toString() ?? ""; | ||
| const f = l.status ?? void 0; | ||
| const p = l.signal != null; | ||
| const m = { | ||
| stdout: u, | ||
| stderr: d, | ||
| get exitCode() { | ||
| return m; | ||
| return f; | ||
| }, | ||
| get pid() { | ||
| return d.pid; | ||
| return l.pid; | ||
| }, | ||
| get killed() { | ||
| return h; | ||
| return p; | ||
| }, | ||
| *[Symbol.iterator]() { | ||
| for (const e of [f, p]) { | ||
| for (const e of [u, d]) { | ||
| if (!e) continue; | ||
| const t = e.split(P); | ||
| const t = e.split(N); | ||
| if (t[t.length - 1] === "") t.pop(); | ||
@@ -709,13 +701,13 @@ yield* t; | ||
| }; | ||
| if (i.throwOnError && m !== 0 && m !== void 0) throw new N(g, g); | ||
| return g; | ||
| if (a.throwOnError && f !== 0 && f !== void 0) throw new M(m, m); | ||
| return m; | ||
| } | ||
| const U = (e, t, n) => { | ||
| const r = new V(e, t, n); | ||
| const V = (e, t, n) => { | ||
| const r = new z(e, t, n); | ||
| r.spawn(); | ||
| return r; | ||
| }; | ||
| const W = U; | ||
| const G = H; | ||
| const H = V; | ||
| const U = B; | ||
| //#endregion | ||
| export { V as ExecProcess, N as NonZeroExitError, W as exec, G as execSync, U as x, H as xSync }; | ||
| export { z as ExecProcess, M as NonZeroExitError, H as exec, U as execSync, V as x, B as xSync }; |
+9
-9
| { | ||
| "name": "tinyexec", | ||
| "version": "1.1.1", | ||
| "version": "1.1.2-next.0", | ||
| "type": "module", | ||
@@ -43,12 +43,12 @@ "description": "A minimal library for executing processes in Node", | ||
| "@types/cross-spawn": "^6.0.6", | ||
| "@types/node": "^25.5.2", | ||
| "@vitest/coverage-v8": "^4.1.2", | ||
| "@types/node": "^25.6.0", | ||
| "@vitest/coverage-v8": "^4.1.5", | ||
| "cross-spawn": "^7.0.6", | ||
| "eslint": "^10.2.0", | ||
| "prettier": "^3.8.1", | ||
| "eslint": "^10.2.1", | ||
| "prettier": "^3.8.3", | ||
| "publint": "^0.3.18", | ||
| "rollup-plugin-license": "^3.7.0", | ||
| "tsdown": "^0.21.7", | ||
| "typescript": "^6.0.2", | ||
| "typescript-eslint": "^8.58.0", | ||
| "rollup-plugin-license": "^3.7.1", | ||
| "tsdown": "^0.21.10", | ||
| "typescript": "^6.0.3", | ||
| "typescript-eslint": "^8.59.1", | ||
| "vitest": "^4.0.7" | ||
@@ -55,0 +55,0 @@ }, |
+1
-1
@@ -69,3 +69,3 @@ # tinyexec 📟 | ||
| You can pass a string to `stdin`, which is useful for whitespace-sensitive values and for secrets you shouldn’t be exposed in shell history: | ||
| You can pass a string to `stdin`, which is useful for whitespace-sensitive values and for secrets that shouldn’t be exposed in shell history: | ||
@@ -72,0 +72,0 @@ ```ts |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
35338
-0.25%682
-1.16%1
Infinity%