mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-14 01:50:39 +09:00
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:
parent
5b479652f2
commit
b642d3e06b
1 changed files with 9 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue