fix(scripts): use local pnpm binary in run-node.mjs if global is missing

Allows the gateway to bootstrap in restricted environments where global packages cannot be installed or are not in the PATH. Checks for node_modules/.bin/pnpm before failing.
This commit is contained in:
elliotsecops 2026-01-27 18:22:50 -04:00
parent 07e34e3423
commit 604c2d9919

View File

@ -116,7 +116,15 @@ if (!shouldBuild()) {
} else {
logRunner("Building TypeScript (dist is stale).");
const pnpmArgs = ["exec", compiler, ...projectArgs];
const buildCmd = process.platform === "win32" ? "cmd.exe" : "pnpm";
// PR Fix: Check for local pnpm binary if global might be missing
let pnpmCmd = "pnpm";
const localPnpm = path.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "pnpm.cmd" : "pnpm");
if (fs.existsSync(localPnpm)) {
pnpmCmd = localPnpm;
}
const buildCmd = process.platform === "win32" ? "cmd.exe" : pnpmCmd;
const buildArgs =
process.platform === "win32" ? ["/d", "/s", "/c", "pnpm", ...pnpmArgs] : pnpmArgs;
const build = spawn(buildCmd, buildArgs, {