fix(platform): resolve pnpm via corepack when npm_execpath is absent

Nested tools-dev daemon/desktop builds no longer assume a global pnpm
binary on PATH. Fall back to `corepack pnpm …` on Windows and POSIX
so the documented Corepack startup flow works end-to-end.
This commit is contained in:
wuyangfan 2026-05-26 23:55:15 +08:00
parent f27fbfb3f1
commit 33f99b1a18
2 changed files with 6 additions and 6 deletions

View file

@ -295,9 +295,9 @@ export function createPackageManagerInvocation(args: string[], env: NodeJS.Proce
return createCommandInvocation({ args, command: execPath, env });
}
if (process.platform === "win32") {
return buildCmdShimInvocation("pnpm", args, env);
return buildCmdShimInvocation("corepack", ["pnpm", ...args], env);
}
return { args, command: "pnpm" };
return { args: ["pnpm", ...args], command: "corepack" };
}
function createLoggedStdio(logFd?: number | null): StdioOptions {

View file

@ -370,13 +370,13 @@ describe("createPackageManagerInvocation", () => {
]);
});
it("returns plain pnpm invocation on POSIX without npm_execpath", () => {
it("returns corepack pnpm invocation on POSIX without npm_execpath", () => {
setPlatform("linux");
const invocation = createPackageManagerInvocation(["install"], {} as NodeJS.ProcessEnv);
expect(invocation).toEqual({ args: ["install"], command: "pnpm" });
expect(invocation).toEqual({ args: ["pnpm", "install"], command: "corepack" });
});
it("wraps pnpm through cmd.exe with verbatim arguments on Windows", () => {
it("wraps corepack pnpm through cmd.exe with verbatim arguments on Windows", () => {
setPlatform("win32");
const invocation = createPackageManagerInvocation(["--filter", "@open-design/desktop", "build"], {
ComSpec: "cmd.exe",
@ -387,7 +387,7 @@ describe("createPackageManagerInvocation", () => {
"/d",
"/s",
"/c",
'"pnpm --filter @open-design/desktop build"',
'"corepack pnpm --filter @open-design/desktop build"',
]);
});
});