+1
-0
@@ -90,2 +90,3 @@ import { ChildProcess, SpawnOptions, SpawnSyncOptions } from "node:child_process"; | ||
| protected _onError: (err: Error) => void; | ||
| protected _onExit: () => void; | ||
| protected _onClose: () => void; | ||
@@ -92,0 +93,0 @@ } |
+36
-19
@@ -185,9 +185,10 @@ import { spawn as e, spawnSync as t } from "node:child_process"; | ||
| const A = /\r?\n/; | ||
| const j = { | ||
| const j = /* @__PURE__ */ new WeakSet(); | ||
| const M = { | ||
| timeout: void 0, | ||
| persist: false | ||
| }; | ||
| const M = { timeout: void 0 }; | ||
| const N = { windowsHide: true }; | ||
| function P(e) { | ||
| const N = { timeout: void 0 }; | ||
| const P = { windowsHide: true }; | ||
| function F(e) { | ||
| const t = new AbortController(); | ||
@@ -206,3 +207,3 @@ for (const n of e) { | ||
| } | ||
| async function F(e) { | ||
| async function I(e) { | ||
| let t = ""; | ||
@@ -214,3 +215,3 @@ try { | ||
| } | ||
| var I = class { | ||
| var L = class { | ||
| _process; | ||
@@ -235,3 +236,3 @@ _aborted = false; | ||
| this._options = { | ||
| ...j, | ||
| ...M, | ||
| ...n | ||
@@ -255,3 +256,3 @@ }; | ||
| pipe(e, t, n) { | ||
| return z(e, t, { | ||
| return B(e, t, { | ||
| ...n, | ||
@@ -278,3 +279,3 @@ stdin: this | ||
| if (!e) throw new Error("No process was started"); | ||
| const [t, n] = await Promise.all([this._streamOut ? F(this._streamOut) : "", this._streamErr ? F(this._streamErr) : ""]); | ||
| const [t, n] = await Promise.all([this._streamOut ? I(this._streamOut) : "", this._streamErr ? I(this._streamErr) : ""]); | ||
| await this._processClosed; | ||
@@ -302,3 +303,3 @@ const { stdin: r } = this._options; | ||
| const i = { | ||
| ...N, | ||
| ...P, | ||
| ...r.nodeOptions | ||
@@ -311,3 +312,3 @@ }; | ||
| if (r.persist === true) i.detached = true; | ||
| if (a.length > 0) i.signal = P(a); | ||
| if (a.length > 0) i.signal = F(a); | ||
| i.env = y(t, i.env, r.nodePath); | ||
@@ -320,2 +321,3 @@ const o = D(this._command, this._args, i); | ||
| s.once("error", this._onError); | ||
| s.once("exit", this._onExit); | ||
| s.once("close", this._onClose); | ||
@@ -325,3 +327,9 @@ if (s.stdin) { | ||
| if (typeof e === "string") s.stdin.end(e); | ||
| else e?.process?.stdout?.pipe(s.stdin); | ||
| else { | ||
| const t = e?.process?.stdout; | ||
| if (t) { | ||
| t.pipe(s.stdin); | ||
| j.add(t); | ||
| } | ||
| } | ||
| } | ||
@@ -343,2 +351,11 @@ } | ||
| }; | ||
| _onExit = () => { | ||
| const e = this._streamOut && !j.has(this._streamOut) ? this._streamOut : void 0; | ||
| const t = this._streamErr && !j.has(this._streamErr) ? this._streamErr : void 0; | ||
| if (!e && !t) return; | ||
| setImmediate(() => { | ||
| e?.destroy(); | ||
| t?.destroy(); | ||
| }); | ||
| }; | ||
| _onClose = () => { | ||
@@ -348,5 +365,5 @@ if (this._resolveClose) this._resolveClose(); | ||
| }; | ||
| function L(e, r, i) { | ||
| function R(e, r, i) { | ||
| const a = { | ||
| ...M, | ||
| ...N, | ||
| ...i | ||
@@ -392,10 +409,10 @@ }; | ||
| } | ||
| const R = (e, t, n) => { | ||
| const r = new I(e, t, n); | ||
| const z = (e, t, n) => { | ||
| const r = new L(e, t, n); | ||
| r.spawn(); | ||
| return r; | ||
| }; | ||
| const z = R; | ||
| const B = L; | ||
| const B = z; | ||
| const V = R; | ||
| //#endregion | ||
| export { I as ExecProcess, k as NonZeroExitError, z as exec, B as execSync, D as normalizeSpawnCommand, R as x, L as xSync }; | ||
| export { L as ExecProcess, k as NonZeroExitError, B as exec, V as execSync, D as normalizeSpawnCommand, z as x, R as xSync }; |
+4
-4
| { | ||
| "name": "tinyexec", | ||
| "version": "1.2.2", | ||
| "version": "1.2.3", | ||
| "type": "module", | ||
@@ -43,4 +43,4 @@ "description": "A minimal library for executing processes in Node", | ||
| "@eslint/js": "^10.0.1", | ||
| "@types/node": "^25.9.0", | ||
| "@vitest/coverage-v8": "^4.1.6", | ||
| "@types/node": "^25.9.1", | ||
| "@vitest/coverage-v8": "^4.1.7", | ||
| "eslint": "^10.4.0", | ||
@@ -51,3 +51,3 @@ "prettier": "^3.8.3", | ||
| "typescript": "^6.0.3", | ||
| "typescript-eslint": "^8.59.4", | ||
| "typescript-eslint": "^8.60.0", | ||
| "vitest": "^4.0.7" | ||
@@ -54,0 +54,0 @@ }, |
23304
1.94%405
4.38%