fix(windows): resolve command execution and binary detection issues

This commit is contained in:
Burak Sormageç
2026-01-30 14:56:46 +00:00
committed by Peter Steinberger
parent 1eccfa8934
commit d7fb01afad
3 changed files with 19 additions and 12 deletions

View File

@@ -99,13 +99,16 @@ export function isBundledSkillAllowed(entry: SkillEntry, allowlist?: string[]):
export function hasBinary(bin: string): boolean {
const pathEnv = process.env.PATH ?? "";
const parts = pathEnv.split(path.delimiter).filter(Boolean);
const extensions = process.platform === "win32" ? [".exe", ".cmd", ".bat", ""] : [""];
for (const part of parts) {
const candidate = path.join(part, bin);
try {
fs.accessSync(candidate, fs.constants.X_OK);
return true;
} catch {
// keep scanning
for (const ext of extensions) {
const candidate = path.join(part, bin + ext);
try {
fs.accessSync(candidate, fs.constants.X_OK);
return true;
} catch {
// keep scanning
}
}
}
return false;

View File

@@ -68,13 +68,16 @@ export function resolveRuntimePlatform(): string {
export function hasBinary(bin: string): boolean {
const pathEnv = process.env.PATH ?? "";
const parts = pathEnv.split(path.delimiter).filter(Boolean);
const extensions = process.platform === "win32" ? [".exe", ".cmd", ".bat", ""] : [""];
for (const part of parts) {
const candidate = path.join(part, bin);
try {
fs.accessSync(candidate, fs.constants.X_OK);
return true;
} catch {
// keep scanning
for (const ext of extensions) {
const candidate = path.join(part, bin + ext);
try {
fs.accessSync(candidate, fs.constants.X_OK);
return true;
} catch {
// keep scanning
}
}
}
return false;

View File

@@ -116,6 +116,7 @@ export async function runCommandWithTimeout(
cwd,
env: resolvedEnv,
windowsVerbatimArguments,
shell: process.platform === "win32",
});
// Spawn with inherited stdin (TTY) so tools like `pi` stay interactive when needed.
return await new Promise((resolve, reject) => {