forked from farhoodlabs/paperclip
fix(adapter-utils): use cmd.exe for .cmd/.bat wrappers on Windows
Avoid relying on ComSpec for .cmd/.bat invocation in runChildProcess. Some Win11 environments set ComSpec to PowerShell, which breaks cmd-specific flags (/d /s /c) and causes adapter CLI discovery failures (e.g. opencode models). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -306,6 +306,12 @@ function quoteForCmd(arg: string) {
|
||||
return /[\s"&<>|^()]/.test(escaped) ? `"${escaped}"` : escaped;
|
||||
}
|
||||
|
||||
function resolveWindowsCmdShell(env: NodeJS.ProcessEnv): string {
|
||||
const fallbackRoot = env.SystemRoot || process.env.SystemRoot || "C:\\Windows";
|
||||
const candidate = path.join(fallbackRoot, "System32", "cmd.exe");
|
||||
return candidate;
|
||||
}
|
||||
|
||||
async function resolveSpawnTarget(
|
||||
command: string,
|
||||
args: string[],
|
||||
@@ -320,7 +326,9 @@ async function resolveSpawnTarget(
|
||||
}
|
||||
|
||||
if (/\.(cmd|bat)$/i.test(executable)) {
|
||||
const shell = env.ComSpec || process.env.ComSpec || "cmd.exe";
|
||||
// Always use cmd.exe for .cmd/.bat wrappers. Some environments override
|
||||
// ComSpec to PowerShell, which breaks cmd-specific flags like /d /s /c.
|
||||
const shell = resolveWindowsCmdShell(env);
|
||||
const commandLine = [quoteForCmd(executable), ...args.map(quoteForCmd)].join(" ");
|
||||
return {
|
||||
command: shell,
|
||||
|
||||
Reference in New Issue
Block a user