fix(memory): stop forcing Windows qmd cmd shims
This commit is contained in:
@@ -72,4 +72,20 @@ describe("resolveCliSpawnInvocation", () => {
|
|||||||
}),
|
}),
|
||||||
).toThrow(/without shell execution/);
|
).toThrow(/without shell execution/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("keeps bare commands bare when no Windows wrapper exists on PATH", () => {
|
||||||
|
process.env.PATH = originalPath ?? "";
|
||||||
|
process.env.PATHEXT = ".CMD;.EXE";
|
||||||
|
|
||||||
|
const invocation = resolveCliSpawnInvocation({
|
||||||
|
command: "qmd",
|
||||||
|
args: ["query", "hello"],
|
||||||
|
env: process.env,
|
||||||
|
packageName: "qmd",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(invocation.command).toBe("qmd");
|
||||||
|
expect(invocation.argv).toEqual(["query", "hello"]);
|
||||||
|
expect(invocation.shell).not.toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { spawn } from "node:child_process";
|
import { spawn } from "node:child_process";
|
||||||
import path from "node:path";
|
|
||||||
import {
|
import {
|
||||||
materializeWindowsSpawnProgram,
|
materializeWindowsSpawnProgram,
|
||||||
resolveWindowsSpawnProgram,
|
resolveWindowsSpawnProgram,
|
||||||
@@ -12,25 +11,6 @@ export type CliSpawnInvocation = {
|
|||||||
windowsHide?: boolean;
|
windowsHide?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
function resolveWindowsCommandShim(command: string): string {
|
|
||||||
if (process.platform !== "win32") {
|
|
||||||
return command;
|
|
||||||
}
|
|
||||||
const trimmed = command.trim();
|
|
||||||
if (!trimmed) {
|
|
||||||
return command;
|
|
||||||
}
|
|
||||||
const ext = path.extname(trimmed).toLowerCase();
|
|
||||||
if (ext === ".cmd" || ext === ".exe" || ext === ".bat") {
|
|
||||||
return command;
|
|
||||||
}
|
|
||||||
const base = path.basename(trimmed).toLowerCase();
|
|
||||||
if (base === "qmd" || base === "mcporter") {
|
|
||||||
return `${trimmed}.cmd`;
|
|
||||||
}
|
|
||||||
return command;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function resolveCliSpawnInvocation(params: {
|
export function resolveCliSpawnInvocation(params: {
|
||||||
command: string;
|
command: string;
|
||||||
args: string[];
|
args: string[];
|
||||||
@@ -38,7 +18,7 @@ export function resolveCliSpawnInvocation(params: {
|
|||||||
packageName: string;
|
packageName: string;
|
||||||
}): CliSpawnInvocation {
|
}): CliSpawnInvocation {
|
||||||
const program = resolveWindowsSpawnProgram({
|
const program = resolveWindowsSpawnProgram({
|
||||||
command: resolveWindowsCommandShim(params.command),
|
command: params.command,
|
||||||
platform: process.platform,
|
platform: process.platform,
|
||||||
env: params.env,
|
env: params.env,
|
||||||
execPath: process.execPath,
|
execPath: process.execPath,
|
||||||
|
|||||||
Reference in New Issue
Block a user