Skip to content

Commit e3741ad

Browse files
committed
fix: wrap bunx with cmd shim on Windows
1 parent 7d2ddf7 commit e3741ad

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/process/exec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function resolveNpmArgvForWindows(argv: string[]): string[] | null {
7979
function resolveCommand(command: string): string {
8080
return resolveWindowsCommandShim({
8181
command,
82-
cmdCommands: ["pnpm", "yarn"],
82+
cmdCommands: ["pnpm", "yarn", "bunx"],
8383
});
8484
}
8585

src/process/exec.windows.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,28 @@ describe("windows command wrapper behavior", () => {
111111
platformSpy.mockRestore();
112112
}
113113
});
114+
115+
it("wraps bunx via cmd.exe in runCommandWithTimeout on Windows", async () => {
116+
const platformSpy = vi.spyOn(process, "platform", "get").mockReturnValue("win32");
117+
const expectedComSpec = process.env.ComSpec ?? "cmd.exe";
118+
119+
spawnMock.mockImplementation(
120+
(_command: string, _args: string[], _options: Record<string, unknown>) => createMockChild(),
121+
);
122+
123+
try {
124+
const result = await runCommandWithTimeout(["bunx", "--version"], { timeoutMs: 1000 });
125+
expect(result.code).toBe(0);
126+
const captured = spawnMock.mock.calls[0] as SpawnCall | undefined;
127+
if (!captured) {
128+
throw new Error("expected command wrapper to be called");
129+
}
130+
expect(captured[0]).toBe(expectedComSpec);
131+
expect(captured[1].slice(0, 3)).toEqual(["/d", "/s", "/c"]);
132+
expect(captured[1][3]).toContain("bunx.cmd --version");
133+
expect(captured[2].windowsVerbatimArguments).toBe(true);
134+
} finally {
135+
platformSpy.mockRestore();
136+
}
137+
});
114138
});

0 commit comments

Comments
 (0)