test(server): reproduce Windows EINVAL for .cmd shim with shell:false
This commit is contained in:
@@ -136,6 +136,22 @@ describe.runIf(process.platform === "win32")("Windows spawn launch regression",
|
|||||||
expect(result.stdout.trim()).toBe("ARGV_OK");
|
expect(result.stdout.trim()).toBe("ARGV_OK");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("launches a cmd shim even when the caller explicitly disables shell", async () => {
|
||||||
|
const fixture = makeFixture();
|
||||||
|
|
||||||
|
const result = await runFixture({
|
||||||
|
command: fixture.shim,
|
||||||
|
args: fixture.expectedArgs,
|
||||||
|
shell: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.error).toBeNull();
|
||||||
|
expect(result.code).toBe(0);
|
||||||
|
expect(result.signal).toBeNull();
|
||||||
|
expect(result.stderr).toBe("");
|
||||||
|
expect(result.stdout.trim()).toBe("ARGV_OK");
|
||||||
|
});
|
||||||
|
|
||||||
test("direct launch with a space-containing executable preserves JSON args", async () => {
|
test("direct launch with a space-containing executable preserves JSON args", async () => {
|
||||||
const fixture = makeFixture();
|
const fixture = makeFixture();
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export function spawnProcess(
|
|||||||
options?: SpawnOptions,
|
options?: SpawnOptions,
|
||||||
): ChildProcess {
|
): ChildProcess {
|
||||||
const isWindows = process.platform === "win32";
|
const isWindows = process.platform === "win32";
|
||||||
const shell = isWindowsCommandScript(command) ? true : (options?.shell ?? isWindows);
|
const shell = options?.shell ?? isWindows;
|
||||||
|
|
||||||
const shouldQuoteForShell = isWindows && shell !== false;
|
const shouldQuoteForShell = isWindows && shell !== false;
|
||||||
const resolvedCommand = shouldQuoteForShell ? quoteWindowsCommand(command) : command;
|
const resolvedCommand = shouldQuoteForShell ? quoteWindowsCommand(command) : command;
|
||||||
|
|||||||
Reference in New Issue
Block a user