fix: add shell: true on Windows so spawnSync can resolve .cmd shims (#13)

On Windows, Node.js `spawnSync` without `shell: true` uses
`CreateProcess`, which only resolves `.exe` files. npm installs global
tools (like `codex`) as `.cmd` shims, so `spawnSync("codex", ...)`
returns ENOENT even when codex is correctly installed and on PATH.

Adding `shell: process.platform === "win32"` routes through `cmd.exe`
on Windows, which properly resolves `.cmd`, `.bat`, and PATHEXT entries.
No behavior change on macOS/Linux since the condition evaluates to false.
This commit is contained in:
Omid Rajabi 2026-03-30 21:54:31 -04:00 committed by GitHub
parent f4d65d9641
commit cf6f8515d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,7 +7,8 @@ export function runCommand(command, args = [], options = {}) {
env: options.env,
encoding: "utf8",
input: options.input,
stdio: options.stdio ?? "pipe"
stdio: options.stdio ?? "pipe",
shell: process.platform === "win32"
});
return {