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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user