fix: quote Windows UI runner paths

This commit is contained in:
Peter Steinberger
2026-04-26 08:30:46 +01:00
parent 434c8a1c91
commit 4c7a94aac4
3 changed files with 22 additions and 3 deletions

View File

@@ -1,5 +1,9 @@
import { describe, expect, it } from "vitest";
import { assertSafeWindowsShellArgs, shouldUseShellForCommand } from "../../scripts/ui.js";
import {
assertSafeWindowsShellArgs,
prepareSpawnCommand,
shouldUseShellForCommand,
} from "../../scripts/ui.js";
describe("scripts/ui windows spawn behavior", () => {
it("enables shell for Windows command launchers that require cmd.exe", () => {
@@ -14,6 +18,16 @@ describe("scripts/ui windows spawn behavior", () => {
expect(shouldUseShellForCommand("/usr/local/bin/pnpm", "linux")).toBe(false);
});
it("quotes Windows shell launcher paths before passing them to spawn", () => {
expect(prepareSpawnCommand("C:\\Program Files\\nodejs\\pnpm.cmd", "win32")).toBe(
'"C:\\Program Files\\nodejs\\pnpm.cmd"',
);
expect(prepareSpawnCommand("C:\\Program Files\\nodejs\\pnpm.exe", "win32")).toBe(
"C:\\Program Files\\nodejs\\pnpm.exe",
);
expect(prepareSpawnCommand("/usr/local/bin/pnpm", "linux")).toBe("/usr/local/bin/pnpm");
});
it("allows safe forwarded args when shell mode is required on Windows", () => {
expect(() =>
assertSafeWindowsShellArgs(["run", "build", "--filter", "@openclaw/ui"], "win32"),