diff --git a/src/process/exec.ts b/src/process/exec.ts index 0e8397c64..d77af40ef 100644 --- a/src/process/exec.ts +++ b/src/process/exec.ts @@ -80,12 +80,15 @@ export async function runCommandWithTimeout( } const stdio = resolveCommandStdio({ hasInput, preferInherit: true }); + const cmdTool = path.parse(argv[0] ?? "").name; + const needsShell = + process.platform === "win32" && ["npm", "pnpm", "yarn", "npx"].includes(cmdTool); const child = spawn(argv[0], argv.slice(1), { stdio, cwd, env: resolvedEnv, windowsVerbatimArguments, - shell: process.platform === "win32", + shell: needsShell, }); // Spawn with inherited stdin (TTY) so tools like `pi` stay interactive when needed. return await new Promise((resolve, reject) => {