From ae7b132f62402e8bf3a0244de0bd8c9607e7ef29 Mon Sep 17 00:00:00 2001 From: imccyu <276526105+imccyu@users.noreply.github.com> Date: Wed, 15 Jul 2026 17:47:29 +0800 Subject: [PATCH] fix: launch pnpm gates without a Windows shell --- scripts/run-gates.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/run-gates.ts b/scripts/run-gates.ts index 4de4742c9d..da87a84db9 100644 --- a/scripts/run-gates.ts +++ b/scripts/run-gates.ts @@ -96,8 +96,7 @@ function pnpmScript(id: string, script: string, options: Partial = {}): Ga return { id, label: options.label ?? script, - command: pnpmBin(), - args: ['run', script], + ...pnpmInvocation(['run', script]), ...options, } } @@ -106,14 +105,18 @@ function pnpmExec(id: string, args: string[], options: Partial = {}): Gate return { id, label: options.label ?? `pnpm exec ${args.join(' ')}`, - command: pnpmBin(), - args: ['exec', ...args], + ...pnpmInvocation(['exec', ...args]), ...options, } } -function pnpmBin(): string { - return process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm' +function pnpmInvocation(args: string[]): Pick { + const entrypoint = process.env.npm_execpath + if (entrypoint === undefined || entrypoint === '') { + throw new Error('run-gates: npm_execpath is unavailable; invoke the runner through a pnpm package script.') + } + // Windows cannot spawn the pnpm.cmd shim directly; the JavaScript entrypoint keeps every host shell-free. + return { command: process.execPath, args: [entrypoint, ...args] } } function nodeOptions(...options: string[]): string { @@ -297,8 +300,7 @@ function demoSmokeGate(options: { needs?: string[] } = {}): Gate { return { id: 'demo-smoke', label: 'demo smoke', - command: pnpmBin(), - args: ['run', 'demo:echo'], + ...pnpmInvocation(['run', 'demo:echo']), input: 'echo ci smoke\n', ...dependencyOptions, verify: async (result) => {