fix(server): harden findExecutable + remove gratuitous realpath from spawn paths (#787)

* Phase 0: baseline tests for probeExecutable

* Phase 1: invert self node env handling

* Phase 2: refactor probeExecutable to execCommand

* Phase 3: push POSIX executable lookup to system which

* Fix probe test spawn-failure fixture

* Guard system which executable lookup
This commit is contained in:
Mohamed Boudra
2026-05-07 14:03:15 +08:00
committed by GitHub
parent 5c86956fef
commit 285d4edf23
8 changed files with 324 additions and 118 deletions
+4 -1
View File
@@ -23,8 +23,10 @@ export type SpawnProcessOptions = Omit<SpawnOptions, "env"> & ExternalEnvOptions
interface ExecCommandOptions extends ExternalEnvOptions {
cwd?: string;
encoding?: BufferEncoding;
killSignal?: NodeJS.Signals;
timeout?: number;
maxBuffer?: number;
shell?: boolean | string;
}
interface ExecCommandResult {
@@ -87,7 +89,7 @@ export async function execCommand(
const { baseEnv, env, envOverlay } = options ?? {};
const resolvedBaseEnv = env ?? baseEnv ?? process.env;
const isWindows = process.platform === "win32";
const shell = shouldUseWindowsShell(command);
const shell = shouldUseWindowsShell(command, options?.shell);
const shouldQuoteForShell = isWindows && shell !== false;
const resolvedCommand = shouldQuoteForShell ? quoteWindowsCommand(command) : command;
const resolvedArgs = shouldQuoteForShell ? args.map(quoteWindowsArgument) : args;
@@ -104,6 +106,7 @@ export async function execCommand(
cwd: options?.cwd,
env: childEnv,
encoding: options?.encoding ?? "utf8",
killSignal: options?.killSignal,
timeout: options?.timeout,
maxBuffer: options?.maxBuffer,
shell,