fix(cli): resolve npx shims on Windows (#1626)

This commit is contained in:
Miguel Ángel
2026-06-21 17:50:22 -04:00
committed by GitHub
parent 6c71cf0240
commit 25b717dd9c
6 changed files with 139 additions and 8 deletions
+17
View File
@@ -0,0 +1,17 @@
export type NpxCommand = {
command: string;
args: string[];
};
export function buildNpxCommand(
args: readonly string[],
platform: NodeJS.Platform = process.platform,
): NpxCommand {
if (platform === "win32") {
// npm installs npx as a .cmd shim on Windows; invoke it through cmd.exe
// instead of relying on child_process to resolve or execute the shim.
return { command: "cmd.exe", args: ["/d", "/s", "/c", "npx.cmd", ...args] };
}
return { command: "npx", args: [...args] };
}