@gitkraken/core-gitlens 0.9.9 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -1
- package/dist/git/errors.d.ts +7 -0
- package/dist/git/errors.js +14 -1
- package/dist/git/errors.js.map +1 -1
- package/dist/git/providers/status.d.ts +6 -1
- package/dist/git/run.types.d.ts +9 -4
- package/dist/git-cli/exec/git.js +36 -16
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/providers/diff.d.ts +5 -2
- package/dist/git-cli/providers/diff.js +21 -9
- package/dist/git-cli/providers/diff.js.map +1 -1
- package/dist/git-cli/providers/patch.js +5 -7
- package/dist/git-cli/providers/patch.js.map +1 -1
- package/dist/git-cli/providers/status.d.ts +0 -1
- package/dist/git-cli/providers/status.js +119 -142
- package/dist/git-cli/providers/status.js.map +1 -1
- package/dist/plus/git-github/providers/github/status.d.ts +0 -1
- package/dist/plus/git-github/providers/github/status.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
- package/dist/plus/integrations/reads/drains.d.ts +1 -0
- package/dist/utils/cancellation.d.ts +4 -1
- package/dist/utils/cancellation.js +4 -2
- package/dist/utils/cancellation.js.map +1 -1
- package/dist/utils/env/node/exec.d.ts +5 -1
- package/dist/utils/env/node/exec.js +8 -5
- package/dist/utils/env/node/exec.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancellation.js","names":[],"sources":["../../../utils/src/cancellation.ts"],"sourcesContent":["import { getScopedCounter } from './counter.js';\n\nconst cancellationErrorBrand = Symbol.for('CancellationError');\n\n/**\n * A standalone CancellationError for use in the library.\n * Uses a symbol brand so that both this class and the extension's\n * CancellationError (which extends vscode.CancellationError) are\n * recognized by `isCancellationError`.\n */\nexport class CancellationError extends Error {\n\t// TS-only nominal brand (not read anywhere) — without it, `CancellationError` has the same\n\t// structural shape as any other `Error` subtype, so `isCancellationError`'s negative narrowing\n\t// (`if (isCancellationError(ex)) throw ex;`) collapses an unrelated error union to `never` instead\n\t// of leaving it narrowed. The runtime brand stays a symbol (below) for the cross-realm check.\n\tprivate readonly _cancellationErrorBrand: true = true;\n\n\tconstructor(public readonly original?: Error) {\n\t\tsuper();\n\t\t// A symbol-keyed computed class field can't be typed for `isolatedDeclarations` (only well-known\n\t\t// symbols like `Symbol.iterator` qualify), so the brand is set here with the same runtime shape\n\t\t// (writable/enumerable/configurable) a plain field assignment would produce.\n\t\tObject.defineProperty(this, cancellationErrorBrand, {\n\t\t\tvalue: true,\n\t\t\twritable: true,\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t});\n\t\tthis.name = 'CancellationError';\n\n\t\tif (this.original) {\n\t\t\tif (this.original.message.startsWith('Operation cancelled')) {\n\t\t\t\tthis.message = this.original.message;\n\t\t\t} else {\n\t\t\t\tthis.message = `Operation cancelled; ${this.original.message}`;\n\t\t\t}\n\t\t} else {\n\t\t\tthis.message = 'Operation cancelled';\n\t\t}\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\nexport function isCancellationError(ex: unknown): ex is CancellationError {\n\treturn (\n\t\t(ex instanceof Error && (cancellationErrorBrand in ex || ex.name === 'CancellationError')) ||\n\t\t(ex instanceof DOMException && ex.name === 'AbortError')\n\t);\n}\n\n/**\n * Races a promise against an `AbortSignal`. If the signal fires before\n * the promise settles, the returned promise rejects with `CancellationError`.\n * If the promise settles first, the signal listener is cleaned up.\n */\nexport function raceWithSignal<T>(promise: Promise<T>, signal: AbortSignal): Promise<T> {\n\tif (signal.aborted) return Promise.reject(new CancellationError());\n\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst onAbort = () => reject(new CancellationError());\n\t\tsignal.addEventListener('abort', onAbort, { once: true });\n\t\tpromise.then(\n\t\t\tv => {\n\t\t\t\tsignal.removeEventListener('abort', onAbort);\n\t\t\t\tresolve(v);\n\t\t\t},\n\t\t\t(e: unknown) => {\n\t\t\t\tsignal.removeEventListener('abort', onAbort);\n\t\t\t\treject(e instanceof Error ? e : new Error(String(e)));\n\t\t\t},\n\t\t);\n\t});\n}\n\n/**\n * Races a promise against a timeout. If `ms` elapses before the promise settles, the returned promise\n * rejects with `CancellationError`. If the promise settles first, the timer is cleared. Parallels\n * `raceWithSignal`, with a timer standing in for the signal.\n *\n * When `abortOnTimeout` is provided, it is aborted on timeout — so a caller can link the underlying operation to\n * it (e.g. via `AbortSignal.any`) and have it torn down instead of orphaned. Abort is best-effort (a truly-stuck\n * op may ignore it); the returned promise rejects on timeout regardless of whether the underlying op settles.\n */\nexport function raceWithTimeout<T>(promise: Promise<T>, ms: number, abortOnTimeout?: AbortController): Promise<T> {\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst timer = setTimeout(() => {\n\t\t\tconst error = new CancellationError(new Error(`Timed out after ${ms}ms`));\n\t\t\tabortOnTimeout?.abort(error);\n\t\t\treject(error);\n\t\t}, ms);\n\t\t// Don't let the timeout timer keep a (Node) process alive on its own — a still-pending promise shouldn't\n\t\t// hold the event loop open just for its backstop (no-op in the browser, where setTimeout returns a number).\n\t\tif (typeof timer !== 'number') {\n\t\t\ttimer.unref();\n\t\t}\n\t\tpromise.then(\n\t\t\tv => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve(v);\n\t\t\t},\n\t\t\t(e: unknown) => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\treject(e instanceof Error ? e : new Error(String(e)));\n\t\t\t},\n\t\t);\n\t});\n}\n\n/**\n * Aggregates multiple caller `AbortSignal`s into a single signal that\n * only fires when **all** callers have cancelled (the inverse of `AbortSignal.any()`).\n *\n * Designed for shared-promise caching: each caller registers their signal,\n * and the underlying operation receives the aggregate signal. Individual callers\n * can cancel early (via `raceWithSignal`), but the operation continues as long\n * as at least one caller is still active.\n */\nexport class AbortAggregate {\n\tprivate readonly controller = new AbortController();\n\tprivate activeCount = 0;\n\t/** One listener-remover per registration (NOT keyed by signal), so adding the same signal twice is safe. */\n\tprivate readonly cleanups = new Set<() => void>();\n\n\t/** The aggregate signal — only fires when all callers have cancelled. */\n\tget signal(): AbortSignal {\n\t\treturn this.controller.signal;\n\t}\n\n\t/**\n\t * Register a caller.\n\t * - If `cancellation` is provided, the caller is auto-removed when it fires.\n\t * - If `cancellation` is `undefined`, the caller is \"permanent\" — the aggregate\n\t * can never fire while it's active. Call the returned cleanup on promise settle.\n\t * - The same signal instance may safely be added more than once — each registration is tracked and cleaned up\n\t * independently, so no listener leaks.\n\t * @returns A cleanup function to unregister the caller.\n\t */\n\tadd(cancellation?: AbortSignal): () => void {\n\t\tthis.activeCount++;\n\n\t\tif (cancellation == null) {\n\t\t\treturn () => {\n\t\t\t\tthis.activeCount--;\n\t\t\t\tthis.checkAbort();\n\t\t\t};\n\t\t}\n\n\t\tif (cancellation.aborted) {\n\t\t\tthis.activeCount--;\n\t\t\tthis.checkAbort();\n\t\t\treturn () => {};\n\t\t}\n\n\t\t// Track this registration's listener removal individually (a Set of removers, NOT keyed by the signal) so\n\t\t// adding the same signal twice can't overwrite the other's cleanup. `settled` keeps both exit paths (abort\n\t\t// vs. manual cleanup) idempotent and preserves the accounting: only `onAbort` decrements `activeCount`.\n\t\tlet settled = false;\n\t\tlet remove: () => void;\n\t\tconst onAbort = () => {\n\t\t\tif (settled) return;\n\n\t\t\tsettled = true;\n\t\t\tthis.cleanups.delete(remove);\n\t\t\tthis.activeCount--;\n\t\t\tthis.checkAbort();\n\t\t};\n\t\tremove = () => cancellation.removeEventListener('abort', onAbort);\n\t\tcancellation.addEventListener('abort', onAbort, { once: true });\n\t\tthis.cleanups.add(remove);\n\n\t\treturn () => {\n\t\t\tif (settled) return;\n\n\t\t\tsettled = true;\n\t\t\tthis.cleanups.delete(remove);\n\t\t\tremove();\n\t\t};\n\t}\n\n\tprivate checkAbort(): void {\n\t\tif (this.activeCount <= 0 && !this.controller.signal.aborted) {\n\t\t\tthis.controller.abort();\n\t\t}\n\t}\n\n\t/** Remove all abort listeners. Call when the cached promise settles. */\n\tdispose(): void {\n\t\tfor (const remove of this.cleanups) {\n\t\t\tremove();\n\t\t}\n\t\tthis.cleanups.clear();\n\t}\n}\n\nconst signalIds = new WeakMap<AbortSignal, number>();\nconst signalIdCounter = getScopedCounter();\n\n/**\n * Returns a stable, unique numeric ID for the given AbortSignal.\n * Used to differentiate concurrent git commands that have different\n * cancellation signals, so one caller aborting doesn't cancel another.\n */\nexport function getAbortSignalId(signal: AbortSignal | undefined): string {\n\tif (signal == null) return '';\n\n\tlet id = signalIds.get(signal);\n\tif (id == null) {\n\t\tid = signalIdCounter.next();\n\t\tsignalIds.set(signal, id);\n\t}\n\treturn String(id);\n}\n"],"mappings":";;AAEA,MAAM,yBAAyB,OAAO,IAAI,mBAAmB;;;;;;;AAQ7D,IAAa,oBAAb,cAAuC,MAAM;CAOhB;CAF5B,0BAAiD;CAEjD,YAAY,UAAkC;EAC7C,MAAM;EADqB,KAAA,WAAA;EAK3B,OAAO,eAAe,MAAM,wBAAwB;GACnD,OAAO;GACP,UAAU;GACV,YAAY;GACZ,cAAc;EACf,CAAC;EACD,KAAK,OAAO;EAEZ,IAAI,KAAK,UAAU;GAClB,IAAI,KAAK,SAAS,QAAQ,WAAW,qBAAqB,GACzD,KAAK,UAAU,KAAK,SAAS;QAE7B,KAAK,UAAU,wBAAwB,KAAK,SAAS;EAEvD,OACC,KAAK,UAAU;EAEhB,MAAM,oBAAoB,MAAM,UAAU;CAC3C;AACD;AAEA,SAAgB,oBAAoB,IAAsC;CACzE,OACE,cAAc,UAAU,0BAA0B,MAAM,GAAG,SAAS,wBACpE,cAAc,gBAAgB,GAAG,SAAS;AAE7C;;;;;;AAOA,SAAgB,eAAkB,SAAqB,QAAiC;CACvF,IAAI,OAAO,SAAS,OAAO,QAAQ,OAAO,IAAI,kBAAkB,CAAC;CAEjE,OAAO,IAAI,SAAY,SAAS,WAAW;EAC1C,MAAM,gBAAgB,OAAO,IAAI,kBAAkB,CAAC;E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,KAAK,WAAW;EACjB;EACA,eAAe,aAAa,oBAAoB,SAAS,OAAO;EAChE,aAAa,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;EAC9D,KAAK,SAAS,IAAI,MAAM;EAExB,aAAa;GACZ,IAAI,SAAS;GAEb,UAAU;GACV,KAAK,SAAS,OAAO,MAAM;GAC3B,OAAO;EACR;CACD;CAEA,aAA2B;EAC1B,IAAI,KAAK,eAAe,KAAK,CAAC,KAAK,WAAW,OAAO,SACpD,KAAK,WAAW,MAAM;CAExB;;CAGA,UAAgB;EACf,KAAK,MAAM,UAAU,KAAK,UACzB,OAAO;EAER,KAAK,SAAS,MAAM;CACrB;AACD;AAEA,MAAM,4BAAY,IAAI,QAA6B;AACnD,MAAM,kBAAkB,iBAAiB;;;;;;AAOzC,SAAgB,iBAAiB,QAAyC;CACzE,IAAI,UAAU,MAAM,OAAO;CAE3B,IAAI,KAAK,UAAU,IAAI,MAAM;CAC7B,IAAI,MAAM,MAAM;EACf,KAAK,gBAAgB,KAAK;EAC1B,UAAU,IAAI,QAAQ,EAAE;CACzB;CACA,OAAO,OAAO,EAAE;AACjB"}
|
|
1
|
+
{"version":3,"file":"cancellation.js","names":[],"sources":["../../../utils/src/cancellation.ts"],"sourcesContent":["import { getScopedCounter } from './counter.js';\n\nconst cancellationErrorBrand = Symbol.for('CancellationError');\n\n/** Why an operation was cancelled: a caller abort, a timeout, or a termination whose cause is unknown. */\nexport type CancellationReason = 'aborted' | 'timeout' | 'unknown';\n\n/**\n * A standalone CancellationError for use in the library.\n * Uses a symbol brand so that both this class and the extension's\n * CancellationError (which extends vscode.CancellationError) are\n * recognized by `isCancellationError`.\n */\nexport class CancellationError extends Error {\n\t// TS-only nominal brand (not read anywhere) — without it, `CancellationError` has the same\n\t// structural shape as any other `Error` subtype, so `isCancellationError`'s negative narrowing\n\t// (`if (isCancellationError(ex)) throw ex;`) collapses an unrelated error union to `never` instead\n\t// of leaving it narrowed. The runtime brand stays a symbol (below) for the cross-realm check.\n\tprivate readonly _cancellationErrorBrand: true = true;\n\n\tconstructor(\n\t\tpublic readonly original?: Error,\n\t\tpublic readonly reason?: CancellationReason,\n\t) {\n\t\tsuper();\n\t\t// A symbol-keyed computed class field can't be typed for `isolatedDeclarations` (only well-known\n\t\t// symbols like `Symbol.iterator` qualify), so the brand is set here with the same runtime shape\n\t\t// (writable/enumerable/configurable) a plain field assignment would produce.\n\t\tObject.defineProperty(this, cancellationErrorBrand, {\n\t\t\tvalue: true,\n\t\t\twritable: true,\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t});\n\t\tthis.name = 'CancellationError';\n\n\t\tif (this.original) {\n\t\t\tif (this.original.message.startsWith('Operation cancelled')) {\n\t\t\t\tthis.message = this.original.message;\n\t\t\t} else {\n\t\t\t\tthis.message = `Operation cancelled; ${this.original.message}`;\n\t\t\t}\n\t\t} else {\n\t\t\tthis.message = 'Operation cancelled';\n\t\t}\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\nexport function isCancellationError(ex: unknown): ex is CancellationError {\n\treturn (\n\t\t(ex instanceof Error && (cancellationErrorBrand in ex || ex.name === 'CancellationError')) ||\n\t\t(ex instanceof DOMException && ex.name === 'AbortError')\n\t);\n}\n\n/**\n * Races a promise against an `AbortSignal`. If the signal fires before\n * the promise settles, the returned promise rejects with `CancellationError`.\n * If the promise settles first, the signal listener is cleaned up.\n */\nexport function raceWithSignal<T>(promise: Promise<T>, signal: AbortSignal): Promise<T> {\n\tif (signal.aborted) return Promise.reject(new CancellationError());\n\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst onAbort = () => reject(new CancellationError());\n\t\tsignal.addEventListener('abort', onAbort, { once: true });\n\t\tpromise.then(\n\t\t\tv => {\n\t\t\t\tsignal.removeEventListener('abort', onAbort);\n\t\t\t\tresolve(v);\n\t\t\t},\n\t\t\t(e: unknown) => {\n\t\t\t\tsignal.removeEventListener('abort', onAbort);\n\t\t\t\treject(e instanceof Error ? e : new Error(String(e)));\n\t\t\t},\n\t\t);\n\t});\n}\n\n/**\n * Races a promise against a timeout. If `ms` elapses before the promise settles, the returned promise\n * rejects with `CancellationError`. If the promise settles first, the timer is cleared. Parallels\n * `raceWithSignal`, with a timer standing in for the signal.\n *\n * When `abortOnTimeout` is provided, it is aborted on timeout — so a caller can link the underlying operation to\n * it (e.g. via `AbortSignal.any`) and have it torn down instead of orphaned. Abort is best-effort (a truly-stuck\n * op may ignore it); the returned promise rejects on timeout regardless of whether the underlying op settles.\n */\nexport function raceWithTimeout<T>(promise: Promise<T>, ms: number, abortOnTimeout?: AbortController): Promise<T> {\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst timer = setTimeout(() => {\n\t\t\tconst error = new CancellationError(new Error(`Timed out after ${ms}ms`), 'timeout');\n\t\t\tabortOnTimeout?.abort(error);\n\t\t\treject(error);\n\t\t}, ms);\n\t\t// Don't let the timeout timer keep a (Node) process alive on its own — a still-pending promise shouldn't\n\t\t// hold the event loop open just for its backstop (no-op in the browser, where setTimeout returns a number).\n\t\tif (typeof timer !== 'number') {\n\t\t\ttimer.unref();\n\t\t}\n\t\tpromise.then(\n\t\t\tv => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve(v);\n\t\t\t},\n\t\t\t(e: unknown) => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\treject(e instanceof Error ? e : new Error(String(e)));\n\t\t\t},\n\t\t);\n\t});\n}\n\n/**\n * Aggregates multiple caller `AbortSignal`s into a single signal that\n * only fires when **all** callers have cancelled (the inverse of `AbortSignal.any()`).\n *\n * Designed for shared-promise caching: each caller registers their signal,\n * and the underlying operation receives the aggregate signal. Individual callers\n * can cancel early (via `raceWithSignal`), but the operation continues as long\n * as at least one caller is still active.\n */\nexport class AbortAggregate {\n\tprivate readonly controller = new AbortController();\n\tprivate activeCount = 0;\n\t/** One listener-remover per registration (NOT keyed by signal), so adding the same signal twice is safe. */\n\tprivate readonly cleanups = new Set<() => void>();\n\n\t/** The aggregate signal — only fires when all callers have cancelled. */\n\tget signal(): AbortSignal {\n\t\treturn this.controller.signal;\n\t}\n\n\t/**\n\t * Register a caller.\n\t * - If `cancellation` is provided, the caller is auto-removed when it fires.\n\t * - If `cancellation` is `undefined`, the caller is \"permanent\" — the aggregate\n\t * can never fire while it's active. Call the returned cleanup on promise settle.\n\t * - The same signal instance may safely be added more than once — each registration is tracked and cleaned up\n\t * independently, so no listener leaks.\n\t * @returns A cleanup function to unregister the caller.\n\t */\n\tadd(cancellation?: AbortSignal): () => void {\n\t\tthis.activeCount++;\n\n\t\tif (cancellation == null) {\n\t\t\treturn () => {\n\t\t\t\tthis.activeCount--;\n\t\t\t\tthis.checkAbort();\n\t\t\t};\n\t\t}\n\n\t\tif (cancellation.aborted) {\n\t\t\tthis.activeCount--;\n\t\t\tthis.checkAbort();\n\t\t\treturn () => {};\n\t\t}\n\n\t\t// Track this registration's listener removal individually (a Set of removers, NOT keyed by the signal) so\n\t\t// adding the same signal twice can't overwrite the other's cleanup. `settled` keeps both exit paths (abort\n\t\t// vs. manual cleanup) idempotent and preserves the accounting: only `onAbort` decrements `activeCount`.\n\t\tlet settled = false;\n\t\tlet remove: () => void;\n\t\tconst onAbort = () => {\n\t\t\tif (settled) return;\n\n\t\t\tsettled = true;\n\t\t\tthis.cleanups.delete(remove);\n\t\t\tthis.activeCount--;\n\t\t\tthis.checkAbort();\n\t\t};\n\t\tremove = () => cancellation.removeEventListener('abort', onAbort);\n\t\tcancellation.addEventListener('abort', onAbort, { once: true });\n\t\tthis.cleanups.add(remove);\n\n\t\treturn () => {\n\t\t\tif (settled) return;\n\n\t\t\tsettled = true;\n\t\t\tthis.cleanups.delete(remove);\n\t\t\tremove();\n\t\t};\n\t}\n\n\tprivate checkAbort(): void {\n\t\tif (this.activeCount <= 0 && !this.controller.signal.aborted) {\n\t\t\tthis.controller.abort();\n\t\t}\n\t}\n\n\t/** Remove all abort listeners. Call when the cached promise settles. */\n\tdispose(): void {\n\t\tfor (const remove of this.cleanups) {\n\t\t\tremove();\n\t\t}\n\t\tthis.cleanups.clear();\n\t}\n}\n\nconst signalIds = new WeakMap<AbortSignal, number>();\nconst signalIdCounter = getScopedCounter();\n\n/**\n * Returns a stable, unique numeric ID for the given AbortSignal.\n * Used to differentiate concurrent git commands that have different\n * cancellation signals, so one caller aborting doesn't cancel another.\n */\nexport function getAbortSignalId(signal: AbortSignal | undefined): string {\n\tif (signal == null) return '';\n\n\tlet id = signalIds.get(signal);\n\tif (id == null) {\n\t\tid = signalIdCounter.next();\n\t\tsignalIds.set(signal, id);\n\t}\n\treturn String(id);\n}\n"],"mappings":";;AAEA,MAAM,yBAAyB,OAAO,IAAI,mBAAmB;;;;;;;AAW7D,IAAa,oBAAb,cAAuC,MAAM;CAQ3B;CACA;CAJjB,0BAAiD;CAEjD,YACC,UACA,QACC;EACD,MAAM;EAHU,KAAA,WAAA;EACA,KAAA,SAAA;EAMhB,OAAO,eAAe,MAAM,wBAAwB;GACnD,OAAO;GACP,UAAU;GACV,YAAY;GACZ,cAAc;EACf,CAAC;EACD,KAAK,OAAO;EAEZ,IAAI,KAAK,UAAU;GAClB,IAAI,KAAK,SAAS,QAAQ,WAAW,qBAAqB,GACzD,KAAK,UAAU,KAAK,SAAS;QAE7B,KAAK,UAAU,wBAAwB,KAAK,SAAS;EAEvD,OACC,KAAK,UAAU;EAEhB,MAAM,oBAAoB,MAAM,UAAU;CAC3C;AACD;AAEA,SAAgB,oBAAoB,IAAsC;CACzE,OACE,cAAc,UAAU,0BAA0B,MAAM,GAAG,SAAS,wBACpE,cAAc,gBAAgB,GAAG,SAAS;AAE7C;;;;;;AAOA,SAAgB,eAAkB,SAAqB,QAAiC;CACvF,IAAI,OAAO,SAAS,OAAO,QAAQ,OAAO,IAAI,kBAAkB,CAAC;CAEjE,OAAO,IAAI,SAAY,SAAS,WAAW;EAC1C,MAAM,gBAAgB,OAAO,IAAI,kBAAkB,CAAC;EACpD,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAA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,oBAAoB,SAAS,OAAO;EAChE,aAAa,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;EAC9D,KAAK,SAAS,IAAI,MAAM;EAExB,aAAa;GACZ,IAAI,SAAS;GAEb,UAAU;GACV,KAAK,SAAS,OAAO,MAAM;GAC3B,OAAO;EACR;CACD;CAEA,aAA2B;EAC1B,IAAI,KAAK,eAAe,KAAK,CAAC,KAAK,WAAW,OAAO,SACpD,KAAK,WAAW,MAAM;CAExB;;CAGA,UAAgB;EACf,KAAK,MAAM,UAAU,KAAK,UACzB,OAAO;EAER,KAAK,SAAS,MAAM;CACrB;AACD;AAEA,MAAM,4BAAY,IAAI,QAA6B;AACnD,MAAM,kBAAkB,iBAAiB;;;;;;AAOzC,SAAgB,iBAAiB,QAAyC;CACzE,IAAI,UAAU,MAAM,OAAO;CAE3B,IAAI,KAAK,UAAU,IAAI,MAAM;CAC7B,IAAI,MAAM,MAAM;EACf,KAAK,gBAAgB,KAAK;EAC1B,UAAU,IAAI,QAAQ,EAAE;CACzB;CACA,OAAO,OAAO,EAAE;AACjB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CancellationReason } from "../../cancellation.js";
|
|
1
2
|
import { Writable } from "stream";
|
|
2
3
|
//#region ../utils/src/env/node/exec.d.ts
|
|
3
4
|
interface RunErrorContext {
|
|
@@ -17,7 +18,8 @@ export declare class RunError extends Error {
|
|
|
17
18
|
constructor(context: RunErrorContext, stdout: string, stderr: string);
|
|
18
19
|
}
|
|
19
20
|
export declare class CancelledRunError extends RunError {
|
|
20
|
-
|
|
21
|
+
readonly reason: CancellationReason;
|
|
22
|
+
constructor(cmd: string, killed: boolean, code?: number | string | undefined, signal?: NodeJS.Signals, reason?: CancellationReason);
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* Finds the executable and parameters to run on Windows. This method
|
|
@@ -94,6 +96,8 @@ export interface RunExitResult {
|
|
|
94
96
|
readonly exitCode?: number;
|
|
95
97
|
/** Set when the process was terminated by a signal instead of exiting; {@link exitCode} is then absent. */
|
|
96
98
|
readonly signal?: NodeJS.Signals;
|
|
99
|
+
/** Whether Node itself killed the process (its spawn `timeout`), as opposed to an external signal. */
|
|
100
|
+
readonly killed?: boolean;
|
|
97
101
|
}
|
|
98
102
|
export interface RunResult<T extends string | Buffer> extends RunExitResult {
|
|
99
103
|
stdout: T;
|
|
@@ -27,7 +27,8 @@ var RunError = class extends Error {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
var CancelledRunError = class extends RunError {
|
|
30
|
-
|
|
30
|
+
reason;
|
|
31
|
+
constructor(cmd, killed, code, signal = "SIGTERM", reason = "unknown") {
|
|
31
32
|
super({
|
|
32
33
|
message: `Operation cancelled; command=${cmd}`,
|
|
33
34
|
cmd,
|
|
@@ -35,6 +36,7 @@ var CancelledRunError = class extends RunError {
|
|
|
35
36
|
code,
|
|
36
37
|
signal
|
|
37
38
|
}, "", "");
|
|
39
|
+
this.reason = reason;
|
|
38
40
|
this.name = "CancelledRunError";
|
|
39
41
|
Error.captureStackTrace?.(this, new.target);
|
|
40
42
|
}
|
|
@@ -158,7 +160,7 @@ function run(command, args, encoding, options) {
|
|
|
158
160
|
}
|
|
159
161
|
if (error != null) {
|
|
160
162
|
if (error.signal === "SIGTERM") {
|
|
161
|
-
reject(new CancelledRunError(`${command} ${args.join(" ")}`, true, error.code ?? void 0, error.signal));
|
|
163
|
+
reject(new CancelledRunError(`${command} ${args.join(" ")}`, true, error.code ?? void 0, error.signal, cancellation?.aborted ? "aborted" : error.killed ? "timeout" : "unknown"));
|
|
162
164
|
return;
|
|
163
165
|
}
|
|
164
166
|
if (bufferExceededRegex.test(error.message)) error.message = `Command output exceeded the allocated stdout buffer. Set 'options.maxBuffer' to a larger value than ${opts.maxBuffer} bytes`;
|
|
@@ -229,7 +231,7 @@ function runSpawn(command, args, encoding, options) {
|
|
|
229
231
|
}
|
|
230
232
|
proc.once("error", async (ex) => {
|
|
231
233
|
if (ex?.name === "AbortError") {
|
|
232
|
-
reject(new CancelledRunError(`${command} ${args.join(" ")}`, true));
|
|
234
|
+
reject(new CancelledRunError(`${command} ${args.join(" ")}`, true, void 0, void 0, "aborted"));
|
|
233
235
|
return;
|
|
234
236
|
}
|
|
235
237
|
const stdio = getStdio(errorEncoding);
|
|
@@ -240,7 +242,8 @@ function runSpawn(command, args, encoding, options) {
|
|
|
240
242
|
if (options?.exitCodeOnly) {
|
|
241
243
|
resolve({
|
|
242
244
|
exitCode: code ?? void 0,
|
|
243
|
-
signal: signal ?? void 0
|
|
245
|
+
signal: signal ?? void 0,
|
|
246
|
+
killed: proc.killed
|
|
244
247
|
});
|
|
245
248
|
return;
|
|
246
249
|
}
|
|
@@ -249,7 +252,7 @@ function runSpawn(command, args, encoding, options) {
|
|
|
249
252
|
const { stdout, stderr } = stdio instanceof Promise ? await stdio : stdio;
|
|
250
253
|
if (stderr.length && !options?.quiet && scope?.enabled("debug")) scope?.warn(`[EXEC] '${command} ${args.join(" ")}' \u2022 ${stderr}`);
|
|
251
254
|
if (signal === "SIGTERM") {
|
|
252
|
-
reject(new CancelledRunError(`${command} ${args.join(" ")}`, true, code ?? void 0, signal));
|
|
255
|
+
reject(new CancelledRunError(`${command} ${args.join(" ")}`, true, code ?? void 0, signal, proc.killed ? "timeout" : "unknown"));
|
|
253
256
|
return;
|
|
254
257
|
}
|
|
255
258
|
reject(new RunError({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.js","names":["joinPaths"],"sources":["../../../../../utils/src/env/node/exec.ts"],"sourcesContent":["import type { ExecFileException, ExecFileOptions } from 'child_process';\nimport { exec, execFile, spawn } from 'child_process';\nimport type { Stats } from 'fs';\nimport { access, constants } from 'fs';\nimport { stat } from 'fs/promises';\nimport { join as joinPaths } from 'path';\nimport * as process from 'process';\nimport type { Writable } from 'stream';\nimport { getScopedLogger, maybeStartScopedLogger } from '../../logger.scoped.js';\nimport { normalizePath } from '../../path.js';\nimport { isWindows } from './platform.js';\n\n// -- Error types --\n\ninterface RunErrorContext {\n\tmessage: string;\n\tcmd?: string | undefined;\n\tkilled?: boolean | undefined;\n\tcode?: string | number | null | undefined;\n\tsignal?: NodeJS.Signals | undefined;\n}\n\nexport class RunError extends Error {\n\treadonly cmd?: string | undefined;\n\treadonly killed?: boolean | undefined;\n\treadonly code?: string | number | undefined;\n\treadonly signal?: NodeJS.Signals | undefined;\n\treadonly stdout: string;\n\treadonly stderr: string;\n\n\tconstructor(context: RunErrorContext, stdout: string, stderr: string) {\n\t\tsuper(context.message);\n\n\t\tthis.cmd = context.cmd;\n\t\tthis.killed = context.killed;\n\t\tthis.code = context.code ?? undefined;\n\t\tthis.signal = context.signal;\n\t\tthis.stdout = stdout?.trim() ?? '';\n\t\tthis.stderr = stderr?.trim() ?? '';\n\n\t\tthis.name = 'RunError';\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\nexport class CancelledRunError extends RunError {\n\tconstructor(cmd: string, killed: boolean, code?: number | string | undefined, signal: NodeJS.Signals = 'SIGTERM') {\n\t\tsuper(\n\t\t\t{ message: `Operation cancelled; command=${cmd}`, cmd: cmd, killed: killed, code: code, signal: signal },\n\t\t\t'',\n\t\t\t'',\n\t\t);\n\n\t\tthis.name = 'CancelledRunError';\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\n// -- Execution utilities --\n\nconst slashesRegex = /[\\\\/]/;\nconst ps1Regex = /\\.ps1$/i;\nconst batOrCmdRegex = /\\.(bat|cmd)$/i;\nconst jsRegex = /\\.(js)$/i;\n\n/**\n * Search PATH to see if a file exists in any of the path folders.\n *\n * @param {string} exe The file to search for\n * @return {string} A fully qualified path, or the original path if nothing\n * is found\n *\n * @private\n */\nasync function runDownPath(exe: string): Promise<string> {\n\t// NB: Windows won't search PATH looking for executables in spawn like\n\t// Posix does\n\n\t// Files with any directory path don't get this applied\n\tif (slashesRegex.test(exe)) return exe;\n\n\tconst target = joinPaths('.', exe);\n\ttry {\n\t\tconst stats = await stat(target);\n\t\tif (stats?.isFile() && isExecutable(stats)) return target;\n\t} catch {}\n\n\tconst path = process.env.PATH;\n\tif (path != null && path.length !== 0) {\n\t\tconst haystack = path.split(isWindows ? ';' : ':');\n\t\tfor (const p of haystack) {\n\t\t\tconst needle = joinPaths(p, exe);\n\t\t\ttry {\n\t\t\t\tconst stats = await stat(needle);\n\t\t\t\tif (stats?.isFile() && isExecutable(stats)) return needle;\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\treturn exe;\n}\n\nfunction isExecutable(stats: Stats) {\n\tif (isWindows) return true;\n\n\tconst isGroup = stats.gid ? stats.gid === process.getgid?.() : true;\n\tconst isUser = stats.uid ? stats.uid === process.getuid?.() : true;\n\n\treturn Boolean(stats.mode & 0o0001 || (stats.mode & 0o0010 && isGroup) || (stats.mode & 0o0100 && isUser));\n}\n\n/**\n * Finds the executable and parameters to run on Windows. This method\n * mimics the POSIX behavior of being able to run scripts as executables by\n * replacing the passed-in executable with the script runner, for PowerShell,\n * CMD, and node scripts.\n *\n * This method also does the work of running down PATH, which spawn on Windows\n * also doesn't do, unlike on POSIX.\n */\nexport async function findExecutable(exe: string, args: string[]): Promise<{ cmd: string; args: string[] }> {\n\t// POSIX can just execute scripts directly, no need for silly goosery\n\tif (!isWindows) return { cmd: await runDownPath(exe), args: args };\n\n\tif (!(await fsExists(exe))) {\n\t\t// NB: When you write something like `surf-client ... -- surf-build` on Windows,\n\t\t// a shell would normally convert that to surf-build.cmd, but since it's passed\n\t\t// in as an argument, it doesn't happen\n\t\tconst possibleExts = ['.exe', '.bat', '.cmd', '.ps1'];\n\t\tfor (const ext of possibleExts) {\n\t\t\tconst possibleFullPath = await runDownPath(`${exe}${ext}`);\n\n\t\t\tif (await fsExists(possibleFullPath)) return findExecutable(possibleFullPath, args);\n\t\t}\n\t}\n\n\tif (ps1Regex.test(exe)) {\n\t\tconst cmd = joinPaths(\n\t\t\tprocess.env.SYSTEMROOT ?? 'C:\\\\WINDOWS',\n\t\t\t'System32',\n\t\t\t'WindowsPowerShell',\n\t\t\t'v1.0',\n\t\t\t'PowerShell.exe',\n\t\t);\n\t\tconst psargs = ['-ExecutionPolicy', 'Unrestricted', '-NoLogo', '-NonInteractive', '-File', exe];\n\n\t\treturn { cmd: cmd, args: [...psargs, ...args] };\n\t}\n\n\tif (batOrCmdRegex.test(exe)) {\n\t\tconst cmd = joinPaths(process.env.SYSTEMROOT ?? 'C:\\\\WINDOWS', 'System32', 'cmd.exe');\n\t\tconst cmdArgs = ['/C', exe, ...args];\n\n\t\treturn { cmd: cmd, args: cmdArgs };\n\t}\n\n\tif (jsRegex.test(exe)) {\n\t\tconst cmd = process.execPath;\n\t\tconst nodeArgs = [exe];\n\n\t\treturn { cmd: cmd, args: [...nodeArgs, ...args] };\n\t}\n\n\treturn { cmd: exe, args: args };\n}\n\nexport async function getWindowsShortPath(path: string): Promise<string> {\n\treturn new Promise<string>((resolve, reject) => {\n\t\texec(`for %I in (\"${path}\") do @echo %~sI`, (error, stdout, _stderr) => {\n\t\t\tif (error != null) {\n\t\t\t\treject(error);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tresolve(normalizePath(stdout.trim()));\n\t\t});\n\t});\n}\n\nexport interface RunOptions<TEncoding = BufferEncoding | 'buffer'> {\n\tcwd?: string;\n\treadonly env?: Record<string, string | undefined>;\n\treadonly encoding?: TEncoding;\n\t/**\n\t * Decodes non-UTF-8 output. Called when `encoding` is not utf8/binary/buffer.\n\t * Provided by the host via the `GitOptions.decode` option.\n\t * If absent and a non-UTF-8 encoding is requested, throws at runtime.\n\t */\n\treadonly decode?: (data: Uint8Array, options?: { readonly encoding: string }) => string | Promise<string>;\n\t/**\n\t * The size the output buffer to allocate to the spawned process. Set this\n\t * if you are anticipating a large amount of output.\n\t *\n\t * If not specified, this will be 10MB (10485760 bytes) which should be\n\t * enough for most Git operations.\n\t */\n\treadonly maxBuffer?: number;\n\treadonly cancellation?: AbortSignal;\n\t/**\n\t * An optional string or buffer which will be written to\n\t * the child process stdin stream immediately immediately\n\t * after spawning the process.\n\t */\n\treadonly stdin?: string | Buffer;\n\t/**\n\t * The encoding to use when writing to stdin, if the stdin\n\t * parameter is a string.\n\t */\n\treadonly stdinEncoding?: string;\n\treadonly timeout?: number;\n\t/**\n\t * When true, suppresses the `[EXEC]` stderr warning emitted on debug-enabled scopes.\n\t * Use for commands whose failure is expected (e.g. paired with `errors: 'ignore'`).\n\t */\n\treadonly quiet?: boolean;\n}\n\nconst bufferExceededRegex = /stdout maxBuffer( length)? exceeded/;\n\ntype ExitCodeOnlyRunOptions<TEncoding = BufferEncoding | 'buffer'> = RunOptions<TEncoding> & { exitCodeOnly: true };\n\nexport function run(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions: ExitCodeOnlyRunOptions<BufferEncoding>,\n): Promise<number>;\nexport function run(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions?: RunOptions<BufferEncoding>,\n): Promise<string>;\nexport function run<T extends number | string>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions?: RunOptions<BufferEncoding> & { exitCodeOnly?: boolean },\n): Promise<T> {\n\tconst scope = getScopedLogger() ?? maybeStartScopedLogger('Exec.run');\n\n\tconst { stdin, stdinEncoding, cancellation, decode, ...opts }: RunOptions<BufferEncoding> & ExecFileOptions = {\n\t\tmaxBuffer: 1000 * 1024 * 1024,\n\t\t...options,\n\t};\n\n\tconst promise = new Promise<T>((resolve, reject) => {\n\t\tconst proc = execFile(\n\t\t\tcommand,\n\t\t\targs,\n\t\t\t{ ...opts, signal: cancellation },\n\t\t\tasync (error: ExecFileException | null, stdout, stderr) => {\n\t\t\t\tif (options?.exitCodeOnly) {\n\t\t\t\t\tresolve((error?.code ?? proc.exitCode) as T);\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (error != null) {\n\t\t\t\t\tif (error.signal === 'SIGTERM') {\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew CancelledRunError(\n\t\t\t\t\t\t\t\t`${command} ${args.join(' ')}`,\n\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\terror.code ?? undefined,\n\t\t\t\t\t\t\t\terror.signal,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (bufferExceededRegex.test(error.message)) {\n\t\t\t\t\t\terror.message = `Command output exceeded the allocated stdout buffer. Set 'options.maxBuffer' to a larger value than ${opts.maxBuffer} bytes`;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet stdoutDecoded: string;\n\t\t\t\t\tlet stderrDecoded: string;\n\t\t\t\t\tif (encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer') {\n\t\t\t\t\t\t// stdout & stderr can be `Buffer` or `string\n\t\t\t\t\t\t// oxlint-disable-next-line typescript/no-unnecessary-type-conversion\n\t\t\t\t\t\tstdoutDecoded = stdout.toString();\n\t\t\t\t\t\t// oxlint-disable-next-line typescript/no-unnecessary-type-conversion\n\t\t\t\t\t\tstderrDecoded = stderr.toString();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (decode == null) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tstdoutDecoded = await decode(\n\t\t\t\t\t\t\tBuffer.from(stdout, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tstderrDecoded = await decode(\n\t\t\t\t\t\t\tBuffer.from(stderr, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treject(new RunError(error, stdoutDecoded, stderrDecoded));\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (stderr && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\t\tscope?.warn(`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${stderr}`);\n\t\t\t\t}\n\n\t\t\t\tif (encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer') {\n\t\t\t\t\tresolve(stdout as T);\n\t\t\t\t} else {\n\t\t\t\t\tif (decode == null) {\n\t\t\t\t\t\tthrow new Error(`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`);\n\t\t\t\t\t}\n\n\t\t\t\t\tresolve(\n\t\t\t\t\t\t(await decode(\n\t\t\t\t\t\t\tBuffer.from(stdout, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t)) as T,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tif (stdin != null) {\n\t\t\tendStdin(proc.stdin, stdin, stdinEncoding);\n\t\t}\n\t});\n\n\treturn promise.finally(() => scope?.[Symbol.dispose]());\n}\n\n/**\n * Writes a child's whole input and closes it. A child can exit, or be killed on cancellation, before reading all of\n * it, and the pipe then errors (EPIPE, or EOF on Windows). Unlistened, that error is thrown as an uncaught exception\n * and takes down the whole host process, so it is dropped: the child's exit status and stderr already report the\n * failure, and a child that chose to stop reading answered from what it read.\n */\nexport function endStdin(stream: Writable | null, stdin: string | Buffer, stdinEncoding: string | undefined): void {\n\tif (stream == null) return;\n\n\tstream.on('error', () => {});\n\tif (typeof stdin === 'string') {\n\t\tstream.end(stdin, (stdinEncoding ?? 'utf8') as BufferEncoding);\n\t} else {\n\t\tstream.end(stdin);\n\t}\n}\n\nexport interface RunExitResult {\n\t/**\n\t * The process's exit code. ABSENT when the process never exited normally — killed by a signal, in which\n\t * case {@link signal} is set. Deliberately optional rather than defaulted to `0`: a signalled process\n\t * reported as `exitCode: 0` is indistinguishable from a clean success, so callers would read a partial\n\t * or empty stdout as a complete answer.\n\t */\n\treadonly exitCode?: number;\n\t/** Set when the process was terminated by a signal instead of exiting; {@link exitCode} is then absent. */\n\treadonly signal?: NodeJS.Signals;\n}\n\nexport interface RunResult<T extends string | Buffer> extends RunExitResult {\n\tstdout: T;\n\tstderr: T;\n}\n\nexport function runSpawn(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: ExitCodeOnlyRunOptions,\n): Promise<RunExitResult>;\nexport function runSpawn<T extends string | Buffer>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: RunOptions,\n): Promise<RunResult<T>>;\nexport function runSpawn<T extends string | Buffer>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: RunOptions & { exitCodeOnly?: boolean },\n): Promise<RunExitResult | RunResult<T>> {\n\tconst scope = getScopedLogger() ?? maybeStartScopedLogger('Exec.runSpawn');\n\n\tconst { stdin, stdinEncoding, cancellation, decode, ...opts }: RunOptions = options;\n\n\tconst promise = new Promise<RunExitResult | RunResult<T>>((resolve, reject) => {\n\t\tconst proc = spawn(command, args, { ...opts, signal: cancellation });\n\t\tconst errorEncoding = encoding === 'buffer' ? 'utf8' : encoding;\n\n\t\tconst stdoutBuffers: Buffer[] = [];\n\t\tproc.stdout.on('data', (data: Buffer) => stdoutBuffers.push(data));\n\n\t\tconst stderrBuffers: Buffer[] = [];\n\t\tproc.stderr.on('data', (data: Buffer) => stderrBuffers.push(data));\n\n\t\tfunction getStdio<T>(\n\t\t\tencoding: BufferEncoding | 'buffer' | string,\n\t\t): { stdout: T; stderr: T } | Promise<{ stdout: T; stderr: T }> {\n\t\t\tconst stdout = Buffer.concat(stdoutBuffers);\n\t\t\tconst stderr = Buffer.concat(stderrBuffers);\n\t\t\tif (encoding === 'utf8' || encoding === 'binary') {\n\t\t\t\treturn { stdout: stdout.toString(encoding) as T, stderr: stderr.toString(encoding) as T };\n\t\t\t}\n\t\t\tif (encoding === 'buffer') {\n\t\t\t\treturn { stdout: stdout as T, stderr: stderr as T };\n\t\t\t}\n\n\t\t\tif (decode == null) {\n\t\t\t\tthrow new Error(`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`);\n\t\t\t}\n\n\t\t\treturn Promise.all([\n\t\t\t\tdecode(stdout, encoding ? { encoding: encoding } : undefined),\n\t\t\t\tdecode(stderr, encoding ? { encoding: encoding } : undefined),\n\t\t\t]).then(([decodedStdout, decodedStderr]) => ({\n\t\t\t\tstdout: decodedStdout as T,\n\t\t\t\tstderr: decodedStderr as T,\n\t\t\t}));\n\t\t}\n\n\t\tproc.once('error', async ex => {\n\t\t\tif (ex?.name === 'AbortError') {\n\t\t\t\treject(new CancelledRunError(`${command} ${args.join(' ')}`, true));\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst stdio = getStdio<string>(errorEncoding);\n\t\t\tconst { stdout, stderr } = stdio instanceof Promise ? await stdio : stdio;\n\n\t\t\treject(new RunError(ex, stdout, stderr));\n\t\t});\n\n\t\tproc.once('close', async (code, signal) => {\n\t\t\tif (options?.exitCodeOnly) {\n\t\t\t\t// Resolves unconditionally, so this is the one path that can hand back a signalled run. `code`\n\t\t\t\t// is null exactly when the process was killed — report the signal rather than coercing to `0`,\n\t\t\t\t// which would claim a clean success for a command that never finished. Note this returns BEFORE\n\t\t\t\t// the SIGTERM-to-cancellation diversion below, so callers have to classify that themselves.\n\t\t\t\tresolve({ exitCode: code ?? undefined, signal: signal ?? undefined });\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (code !== 0 || signal) {\n\t\t\t\tconst stdio = getStdio<string>(errorEncoding);\n\t\t\t\tconst { stdout, stderr } = stdio instanceof Promise ? await stdio : stdio;\n\t\t\t\tif (stderr.length && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\t\tscope?.warn(`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${stderr}`);\n\t\t\t\t}\n\n\t\t\t\tif (signal === 'SIGTERM') {\n\t\t\t\t\treject(new CancelledRunError(`${command} ${args.join(' ')}`, true, code ?? undefined, signal));\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\treject(\n\t\t\t\t\tnew RunError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmessage: `Command failed with exit code ${code}`,\n\t\t\t\t\t\t\tcode: code,\n\t\t\t\t\t\t\tsignal: signal ?? undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tstdout,\n\t\t\t\t\t\tstderr,\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst stdio = getStdio<T>(encoding);\n\t\t\tconst { stdout, stderr } = stdio instanceof Promise ? await stdio : stdio;\n\t\t\tif (stderr.length && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\tscope?.warn(\n\t\t\t\t\t`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${typeof stderr === 'string' ? stderr : stderr.toString()}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// The guard above already rejected every non-zero and every signalled close, so this is a clean\n\t\t\t// zero exit — `code` cannot be null here. (The optional typing exists for the `exitCodeOnly`\n\t\t\t// branch, which is where a codeless result can genuinely surface.)\n\t\t\tresolve({ exitCode: code ?? undefined, signal: signal ?? undefined, stdout: stdout, stderr: stderr });\n\t\t});\n\n\t\tif (stdin != null) {\n\t\t\tendStdin(proc.stdin, stdin, stdinEncoding);\n\t\t}\n\t});\n\n\treturn promise.finally(() => scope?.[Symbol.dispose]());\n}\n\nexport async function fsExists(path: string): Promise<boolean> {\n\treturn new Promise<boolean>(resolve => access(path, constants.F_OK, err => resolve(err == null)));\n}\n"],"mappings":";;;;;;;;;AAsBA,IAAa,WAAb,cAA8B,MAAM;CACnC;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,SAA0B,QAAgB,QAAgB;EACrE,MAAM,QAAQ,OAAO;EAErB,KAAK,MAAM,QAAQ;EACnB,KAAK,SAAS,QAAQ;EAC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,GAAW,MAAM,CAAC;KAE7F;IACD;IAEA,OACC,IAAI,SACH;KACC,SAAS,iCAAiC;KACpC;KACN,QAAQ,UAAU,KAAA;IACnB,GACA,QACA,MACD,CACD;IAEA;GACD;GAEA,MAAM,QAAQ,SAAY,QAAQ;GAClC,MAAM,EAAE,QAAQ,WAAW,iBAAiB,UAAU,MAAM,QAAQ;GACpE,IAAI,OAAO,UAAU,CAAC,SAAS,SAAS,OAAO,QAAQ,OAAO,GAC7D,OAAO,KACN,WAAW,QAAQ,GAAG,KAAK,KAAK,GAAG,EAAE,WAAW,OAAO,WAAW,WAAW,SAAS,OAAO,SAAS,GACvG;GAMD,QAAQ;IAAE,UAAU,QAAQ,KAAA;IAAW,QAAQ,UAAU,KAAA;IAAmB;IAAgB;GAAO,CAAC;EACrG,CAAC;EAED,IAAI,SAAS,MACZ,SAAS,KAAK,OAAO,OAAO,aAAa;CAE3C,CAEa,CAAC,CAAC,cAAc,QAAQ,OAAO,QAAQ,CAAC,CAAC;AACvD;AAEA,eAAsB,SAAS,MAAgC;CAC9D,OAAO,IAAI,SAAiB,YAAW,OAAO,MAAM,UAAU,OAAM,QAAO,QAAQ,OAAO,IAAI,CAAC,CAAC;AACjG"}
|
|
1
|
+
{"version":3,"file":"exec.js","names":["joinPaths"],"sources":["../../../../../utils/src/env/node/exec.ts"],"sourcesContent":["import type { ExecFileException, ExecFileOptions } from 'child_process';\nimport { exec, execFile, spawn } from 'child_process';\nimport type { Stats } from 'fs';\nimport { access, constants } from 'fs';\nimport { stat } from 'fs/promises';\nimport { join as joinPaths } from 'path';\nimport * as process from 'process';\nimport type { Writable } from 'stream';\nimport type { CancellationReason } from '../../cancellation.js';\nimport { getScopedLogger, maybeStartScopedLogger } from '../../logger.scoped.js';\nimport { normalizePath } from '../../path.js';\nimport { isWindows } from './platform.js';\n\n// -- Error types --\n\ninterface RunErrorContext {\n\tmessage: string;\n\tcmd?: string | undefined;\n\tkilled?: boolean | undefined;\n\tcode?: string | number | null | undefined;\n\tsignal?: NodeJS.Signals | undefined;\n}\n\nexport class RunError extends Error {\n\treadonly cmd?: string | undefined;\n\treadonly killed?: boolean | undefined;\n\treadonly code?: string | number | undefined;\n\treadonly signal?: NodeJS.Signals | undefined;\n\treadonly stdout: string;\n\treadonly stderr: string;\n\n\tconstructor(context: RunErrorContext, stdout: string, stderr: string) {\n\t\tsuper(context.message);\n\n\t\tthis.cmd = context.cmd;\n\t\tthis.killed = context.killed;\n\t\tthis.code = context.code ?? undefined;\n\t\tthis.signal = context.signal;\n\t\tthis.stdout = stdout?.trim() ?? '';\n\t\tthis.stderr = stderr?.trim() ?? '';\n\n\t\tthis.name = 'RunError';\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\nexport class CancelledRunError extends RunError {\n\treadonly reason: CancellationReason;\n\n\tconstructor(\n\t\tcmd: string,\n\t\tkilled: boolean,\n\t\tcode?: number | string | undefined,\n\t\tsignal: NodeJS.Signals = 'SIGTERM',\n\t\treason: CancellationReason = 'unknown',\n\t) {\n\t\tsuper(\n\t\t\t{ message: `Operation cancelled; command=${cmd}`, cmd: cmd, killed: killed, code: code, signal: signal },\n\t\t\t'',\n\t\t\t'',\n\t\t);\n\n\t\tthis.reason = reason;\n\n\t\tthis.name = 'CancelledRunError';\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\n// -- Execution utilities --\n\nconst slashesRegex = /[\\\\/]/;\nconst ps1Regex = /\\.ps1$/i;\nconst batOrCmdRegex = /\\.(bat|cmd)$/i;\nconst jsRegex = /\\.(js)$/i;\n\n/**\n * Search PATH to see if a file exists in any of the path folders.\n *\n * @param {string} exe The file to search for\n * @return {string} A fully qualified path, or the original path if nothing\n * is found\n *\n * @private\n */\nasync function runDownPath(exe: string): Promise<string> {\n\t// NB: Windows won't search PATH looking for executables in spawn like\n\t// Posix does\n\n\t// Files with any directory path don't get this applied\n\tif (slashesRegex.test(exe)) return exe;\n\n\tconst target = joinPaths('.', exe);\n\ttry {\n\t\tconst stats = await stat(target);\n\t\tif (stats?.isFile() && isExecutable(stats)) return target;\n\t} catch {}\n\n\tconst path = process.env.PATH;\n\tif (path != null && path.length !== 0) {\n\t\tconst haystack = path.split(isWindows ? ';' : ':');\n\t\tfor (const p of haystack) {\n\t\t\tconst needle = joinPaths(p, exe);\n\t\t\ttry {\n\t\t\t\tconst stats = await stat(needle);\n\t\t\t\tif (stats?.isFile() && isExecutable(stats)) return needle;\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\treturn exe;\n}\n\nfunction isExecutable(stats: Stats) {\n\tif (isWindows) return true;\n\n\tconst isGroup = stats.gid ? stats.gid === process.getgid?.() : true;\n\tconst isUser = stats.uid ? stats.uid === process.getuid?.() : true;\n\n\treturn Boolean(stats.mode & 0o0001 || (stats.mode & 0o0010 && isGroup) || (stats.mode & 0o0100 && isUser));\n}\n\n/**\n * Finds the executable and parameters to run on Windows. This method\n * mimics the POSIX behavior of being able to run scripts as executables by\n * replacing the passed-in executable with the script runner, for PowerShell,\n * CMD, and node scripts.\n *\n * This method also does the work of running down PATH, which spawn on Windows\n * also doesn't do, unlike on POSIX.\n */\nexport async function findExecutable(exe: string, args: string[]): Promise<{ cmd: string; args: string[] }> {\n\t// POSIX can just execute scripts directly, no need for silly goosery\n\tif (!isWindows) return { cmd: await runDownPath(exe), args: args };\n\n\tif (!(await fsExists(exe))) {\n\t\t// NB: When you write something like `surf-client ... -- surf-build` on Windows,\n\t\t// a shell would normally convert that to surf-build.cmd, but since it's passed\n\t\t// in as an argument, it doesn't happen\n\t\tconst possibleExts = ['.exe', '.bat', '.cmd', '.ps1'];\n\t\tfor (const ext of possibleExts) {\n\t\t\tconst possibleFullPath = await runDownPath(`${exe}${ext}`);\n\n\t\t\tif (await fsExists(possibleFullPath)) return findExecutable(possibleFullPath, args);\n\t\t}\n\t}\n\n\tif (ps1Regex.test(exe)) {\n\t\tconst cmd = joinPaths(\n\t\t\tprocess.env.SYSTEMROOT ?? 'C:\\\\WINDOWS',\n\t\t\t'System32',\n\t\t\t'WindowsPowerShell',\n\t\t\t'v1.0',\n\t\t\t'PowerShell.exe',\n\t\t);\n\t\tconst psargs = ['-ExecutionPolicy', 'Unrestricted', '-NoLogo', '-NonInteractive', '-File', exe];\n\n\t\treturn { cmd: cmd, args: [...psargs, ...args] };\n\t}\n\n\tif (batOrCmdRegex.test(exe)) {\n\t\tconst cmd = joinPaths(process.env.SYSTEMROOT ?? 'C:\\\\WINDOWS', 'System32', 'cmd.exe');\n\t\tconst cmdArgs = ['/C', exe, ...args];\n\n\t\treturn { cmd: cmd, args: cmdArgs };\n\t}\n\n\tif (jsRegex.test(exe)) {\n\t\tconst cmd = process.execPath;\n\t\tconst nodeArgs = [exe];\n\n\t\treturn { cmd: cmd, args: [...nodeArgs, ...args] };\n\t}\n\n\treturn { cmd: exe, args: args };\n}\n\nexport async function getWindowsShortPath(path: string): Promise<string> {\n\treturn new Promise<string>((resolve, reject) => {\n\t\texec(`for %I in (\"${path}\") do @echo %~sI`, (error, stdout, _stderr) => {\n\t\t\tif (error != null) {\n\t\t\t\treject(error);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tresolve(normalizePath(stdout.trim()));\n\t\t});\n\t});\n}\n\nexport interface RunOptions<TEncoding = BufferEncoding | 'buffer'> {\n\tcwd?: string;\n\treadonly env?: Record<string, string | undefined>;\n\treadonly encoding?: TEncoding;\n\t/**\n\t * Decodes non-UTF-8 output. Called when `encoding` is not utf8/binary/buffer.\n\t * Provided by the host via the `GitOptions.decode` option.\n\t * If absent and a non-UTF-8 encoding is requested, throws at runtime.\n\t */\n\treadonly decode?: (data: Uint8Array, options?: { readonly encoding: string }) => string | Promise<string>;\n\t/**\n\t * The size the output buffer to allocate to the spawned process. Set this\n\t * if you are anticipating a large amount of output.\n\t *\n\t * If not specified, this will be 10MB (10485760 bytes) which should be\n\t * enough for most Git operations.\n\t */\n\treadonly maxBuffer?: number;\n\treadonly cancellation?: AbortSignal;\n\t/**\n\t * An optional string or buffer which will be written to\n\t * the child process stdin stream immediately immediately\n\t * after spawning the process.\n\t */\n\treadonly stdin?: string | Buffer;\n\t/**\n\t * The encoding to use when writing to stdin, if the stdin\n\t * parameter is a string.\n\t */\n\treadonly stdinEncoding?: string;\n\treadonly timeout?: number;\n\t/**\n\t * When true, suppresses the `[EXEC]` stderr warning emitted on debug-enabled scopes.\n\t * Use for commands whose failure is expected (e.g. paired with `errors: 'ignore'`).\n\t */\n\treadonly quiet?: boolean;\n}\n\nconst bufferExceededRegex = /stdout maxBuffer( length)? exceeded/;\n\ntype ExitCodeOnlyRunOptions<TEncoding = BufferEncoding | 'buffer'> = RunOptions<TEncoding> & { exitCodeOnly: true };\n\nexport function run(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions: ExitCodeOnlyRunOptions<BufferEncoding>,\n): Promise<number>;\nexport function run(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions?: RunOptions<BufferEncoding>,\n): Promise<string>;\nexport function run<T extends number | string>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions?: RunOptions<BufferEncoding> & { exitCodeOnly?: boolean },\n): Promise<T> {\n\tconst scope = getScopedLogger() ?? maybeStartScopedLogger('Exec.run');\n\n\tconst { stdin, stdinEncoding, cancellation, decode, ...opts }: RunOptions<BufferEncoding> & ExecFileOptions = {\n\t\tmaxBuffer: 1000 * 1024 * 1024,\n\t\t...options,\n\t};\n\n\tconst promise = new Promise<T>((resolve, reject) => {\n\t\tconst proc = execFile(\n\t\t\tcommand,\n\t\t\targs,\n\t\t\t{ ...opts, signal: cancellation },\n\t\t\tasync (error: ExecFileException | null, stdout, stderr) => {\n\t\t\t\tif (options?.exitCodeOnly) {\n\t\t\t\t\tresolve((error?.code ?? proc.exitCode) as T);\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (error != null) {\n\t\t\t\t\tif (error.signal === 'SIGTERM') {\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew CancelledRunError(\n\t\t\t\t\t\t\t\t`${command} ${args.join(' ')}`,\n\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\terror.code ?? undefined,\n\t\t\t\t\t\t\t\terror.signal,\n\t\t\t\t\t\t\t\tcancellation?.aborted ? 'aborted' : error.killed ? 'timeout' : 'unknown',\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (bufferExceededRegex.test(error.message)) {\n\t\t\t\t\t\terror.message = `Command output exceeded the allocated stdout buffer. Set 'options.maxBuffer' to a larger value than ${opts.maxBuffer} bytes`;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet stdoutDecoded: string;\n\t\t\t\t\tlet stderrDecoded: string;\n\t\t\t\t\tif (encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer') {\n\t\t\t\t\t\t// stdout & stderr can be `Buffer` or `string\n\t\t\t\t\t\t// oxlint-disable-next-line typescript/no-unnecessary-type-conversion\n\t\t\t\t\t\tstdoutDecoded = stdout.toString();\n\t\t\t\t\t\t// oxlint-disable-next-line typescript/no-unnecessary-type-conversion\n\t\t\t\t\t\tstderrDecoded = stderr.toString();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (decode == null) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tstdoutDecoded = await decode(\n\t\t\t\t\t\t\tBuffer.from(stdout, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tstderrDecoded = await decode(\n\t\t\t\t\t\t\tBuffer.from(stderr, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treject(new RunError(error, stdoutDecoded, stderrDecoded));\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (stderr && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\t\tscope?.warn(`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${stderr}`);\n\t\t\t\t}\n\n\t\t\t\tif (encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer') {\n\t\t\t\t\tresolve(stdout as T);\n\t\t\t\t} else {\n\t\t\t\t\tif (decode == null) {\n\t\t\t\t\t\tthrow new Error(`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`);\n\t\t\t\t\t}\n\n\t\t\t\t\tresolve(\n\t\t\t\t\t\t(await decode(\n\t\t\t\t\t\t\tBuffer.from(stdout, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t)) as T,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tif (stdin != null) {\n\t\t\tendStdin(proc.stdin, stdin, stdinEncoding);\n\t\t}\n\t});\n\n\treturn promise.finally(() => scope?.[Symbol.dispose]());\n}\n\n/**\n * Writes a child's whole input and closes it. A child can exit, or be killed on cancellation, before reading all of\n * it, and the pipe then errors (EPIPE, or EOF on Windows). Unlistened, that error is thrown as an uncaught exception\n * and takes down the whole host process, so it is dropped: the child's exit status and stderr already report the\n * failure, and a child that chose to stop reading answered from what it read.\n */\nexport function endStdin(stream: Writable | null, stdin: string | Buffer, stdinEncoding: string | undefined): void {\n\tif (stream == null) return;\n\n\tstream.on('error', () => {});\n\tif (typeof stdin === 'string') {\n\t\tstream.end(stdin, (stdinEncoding ?? 'utf8') as BufferEncoding);\n\t} else {\n\t\tstream.end(stdin);\n\t}\n}\n\nexport interface RunExitResult {\n\t/**\n\t * The process's exit code. ABSENT when the process never exited normally — killed by a signal, in which\n\t * case {@link signal} is set. Deliberately optional rather than defaulted to `0`: a signalled process\n\t * reported as `exitCode: 0` is indistinguishable from a clean success, so callers would read a partial\n\t * or empty stdout as a complete answer.\n\t */\n\treadonly exitCode?: number;\n\t/** Set when the process was terminated by a signal instead of exiting; {@link exitCode} is then absent. */\n\treadonly signal?: NodeJS.Signals;\n\t/** Whether Node itself killed the process (its spawn `timeout`), as opposed to an external signal. */\n\treadonly killed?: boolean;\n}\n\nexport interface RunResult<T extends string | Buffer> extends RunExitResult {\n\tstdout: T;\n\tstderr: T;\n}\n\nexport function runSpawn(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: ExitCodeOnlyRunOptions,\n): Promise<RunExitResult>;\nexport function runSpawn<T extends string | Buffer>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: RunOptions,\n): Promise<RunResult<T>>;\nexport function runSpawn<T extends string | Buffer>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: RunOptions & { exitCodeOnly?: boolean },\n): Promise<RunExitResult | RunResult<T>> {\n\tconst scope = getScopedLogger() ?? maybeStartScopedLogger('Exec.runSpawn');\n\n\tconst { stdin, stdinEncoding, cancellation, decode, ...opts }: RunOptions = options;\n\n\tconst promise = new Promise<RunExitResult | RunResult<T>>((resolve, reject) => {\n\t\tconst proc = spawn(command, args, { ...opts, signal: cancellation });\n\t\tconst errorEncoding = encoding === 'buffer' ? 'utf8' : encoding;\n\n\t\tconst stdoutBuffers: Buffer[] = [];\n\t\tproc.stdout.on('data', (data: Buffer) => stdoutBuffers.push(data));\n\n\t\tconst stderrBuffers: Buffer[] = [];\n\t\tproc.stderr.on('data', (data: Buffer) => stderrBuffers.push(data));\n\n\t\tfunction getStdio<T>(\n\t\t\tencoding: BufferEncoding | 'buffer' | string,\n\t\t): { stdout: T; stderr: T } | Promise<{ stdout: T; stderr: T }> {\n\t\t\tconst stdout = Buffer.concat(stdoutBuffers);\n\t\t\tconst stderr = Buffer.concat(stderrBuffers);\n\t\t\tif (encoding === 'utf8' || encoding === 'binary') {\n\t\t\t\treturn { stdout: stdout.toString(encoding) as T, stderr: stderr.toString(encoding) as T };\n\t\t\t}\n\t\t\tif (encoding === 'buffer') {\n\t\t\t\treturn { stdout: stdout as T, stderr: stderr as T };\n\t\t\t}\n\n\t\t\tif (decode == null) {\n\t\t\t\tthrow new Error(`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`);\n\t\t\t}\n\n\t\t\treturn Promise.all([\n\t\t\t\tdecode(stdout, encoding ? { encoding: encoding } : undefined),\n\t\t\t\tdecode(stderr, encoding ? { encoding: encoding } : undefined),\n\t\t\t]).then(([decodedStdout, decodedStderr]) => ({\n\t\t\t\tstdout: decodedStdout as T,\n\t\t\t\tstderr: decodedStderr as T,\n\t\t\t}));\n\t\t}\n\n\t\tproc.once('error', async ex => {\n\t\t\tif (ex?.name === 'AbortError') {\n\t\t\t\treject(new CancelledRunError(`${command} ${args.join(' ')}`, true, undefined, undefined, 'aborted'));\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst stdio = getStdio<string>(errorEncoding);\n\t\t\tconst { stdout, stderr } = stdio instanceof Promise ? await stdio : stdio;\n\n\t\t\treject(new RunError(ex, stdout, stderr));\n\t\t});\n\n\t\tproc.once('close', async (code, signal) => {\n\t\t\tif (options?.exitCodeOnly) {\n\t\t\t\t// Resolves unconditionally, so this is the one path that can hand back a signalled run. `code`\n\t\t\t\t// is null exactly when the process was killed — report the signal rather than coercing to `0`,\n\t\t\t\t// which would claim a clean success for a command that never finished. Note this returns BEFORE\n\t\t\t\t// the SIGTERM-to-cancellation diversion below, so callers have to classify that themselves.\n\t\t\t\tresolve({ exitCode: code ?? undefined, signal: signal ?? undefined, killed: proc.killed });\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (code !== 0 || signal) {\n\t\t\t\tconst stdio = getStdio<string>(errorEncoding);\n\t\t\t\tconst { stdout, stderr } = stdio instanceof Promise ? await stdio : stdio;\n\t\t\t\tif (stderr.length && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\t\tscope?.warn(`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${stderr}`);\n\t\t\t\t}\n\n\t\t\t\tif (signal === 'SIGTERM') {\n\t\t\t\t\t// Only Node's spawn `timeout` kills it (a caller abort rejected above, from `'error'`); an\n\t\t\t\t\t// external SIGTERM leaves `proc.killed` false\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew CancelledRunError(\n\t\t\t\t\t\t\t`${command} ${args.join(' ')}`,\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\tcode ?? undefined,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\tproc.killed ? 'timeout' : 'unknown',\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\treject(\n\t\t\t\t\tnew RunError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmessage: `Command failed with exit code ${code}`,\n\t\t\t\t\t\t\tcode: code,\n\t\t\t\t\t\t\tsignal: signal ?? undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tstdout,\n\t\t\t\t\t\tstderr,\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst stdio = getStdio<T>(encoding);\n\t\t\tconst { stdout, stderr } = stdio instanceof Promise ? await stdio : stdio;\n\t\t\tif (stderr.length && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\tscope?.warn(\n\t\t\t\t\t`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${typeof stderr === 'string' ? stderr : stderr.toString()}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// The guard above already rejected every non-zero and every signalled close, so this is a clean\n\t\t\t// zero exit — `code` cannot be null here. (The optional typing exists for the `exitCodeOnly`\n\t\t\t// branch, which is where a codeless result can genuinely surface.)\n\t\t\tresolve({ exitCode: code ?? undefined, signal: signal ?? undefined, stdout: stdout, stderr: stderr });\n\t\t});\n\n\t\tif (stdin != null) {\n\t\t\tendStdin(proc.stdin, stdin, stdinEncoding);\n\t\t}\n\t});\n\n\treturn promise.finally(() => scope?.[Symbol.dispose]());\n}\n\nexport async function fsExists(path: string): Promise<boolean> {\n\treturn new Promise<boolean>(resolve => access(path, constants.F_OK, err => resolve(err == null)));\n}\n"],"mappings":";;;;;;;;;AAuBA,IAAa,WAAb,cAA8B,MAAM;CACnC;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,SAA0B,QAAgB,QAAgB;EACrE,MAAM,QAAQ,OAAO;EAErB,KAAK,MAAM,QAAQ;EACnB,KAAK,SAAS,QAAQ;EACtB,KAAK,OAAO,QAAQ,QAAQ,KAAA;EAC5B,KAAK,SAAS,QAAQ;EACtB,KAAK,SAAS,QAAQ,KAAK,KAAK;EAChC,KAAK,SAAS,QAAQ,KAAK,KAAK;EAEhC,KAAK,OAAO;EACZ,MAAM,oBAAoB,MAAM,UAAU;CAC3C;AACD;AAEA,IAAa,oBAAb,cAAuC,SAAS;CAC/C;CAEA,YACC,KACA,QACA,MACA,SAAyB,WACzB,SAA6B,WAC5B;EACD,MACC;GAAE,SAAS,gCAAgC;GAAY;GAAa;GAAc;GAAc;EAAO,GACvG,IACA,EACD;EAEA,KAAK,SAAS;EAEd,KAAK,OAAO;EACZ,MAAM,oBAAoB,MAAM,UAAU;CAC3C;AACD;AAIA,MAAM,eAAe;AACrB,MAAM,WAAW;AACjB,MAAM,gBAAgB;AACtB,MAAM,UAAU;;;;;;;;;;AAWhB,eAAe,YAAY,KAA8B;CAKxD,IAAI,aAAa,KAAK,GAAG,GAAG,OAAO;CAEnC,MAAM,SAASA,KAAU,KAAK,GAAG;CACjC,IAAI;EACH,MAAM,QAAQ,MAAM,KAAK,MAAM;EAC/B,IAAI,OAAO,OAAO,KAAK,aAAa,KAAK,GAAG,OAAO;CACpD,QAAQ,CAAC;CAET,MAAM,OAAO,QAAQ,IAAI;CACzB,I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