fix: launch pnpm gates without a Windows shell
This commit is contained in:
@@ -96,8 +96,7 @@ function pnpmScript(id: string, script: string, options: Partial<Gate> = {}): Ga
|
|||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
label: options.label ?? script,
|
label: options.label ?? script,
|
||||||
command: pnpmBin(),
|
...pnpmInvocation(['run', script]),
|
||||||
args: ['run', script],
|
|
||||||
...options,
|
...options,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,14 +105,18 @@ function pnpmExec(id: string, args: string[], options: Partial<Gate> = {}): Gate
|
|||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
label: options.label ?? `pnpm exec ${args.join(' ')}`,
|
label: options.label ?? `pnpm exec ${args.join(' ')}`,
|
||||||
command: pnpmBin(),
|
...pnpmInvocation(['exec', ...args]),
|
||||||
args: ['exec', ...args],
|
|
||||||
...options,
|
...options,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pnpmBin(): string {
|
function pnpmInvocation(args: string[]): Pick<Gate, 'command' | 'args'> {
|
||||||
return process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'
|
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 {
|
function nodeOptions(...options: string[]): string {
|
||||||
@@ -297,8 +300,7 @@ function demoSmokeGate(options: { needs?: string[] } = {}): Gate {
|
|||||||
return {
|
return {
|
||||||
id: 'demo-smoke',
|
id: 'demo-smoke',
|
||||||
label: 'demo smoke',
|
label: 'demo smoke',
|
||||||
command: pnpmBin(),
|
...pnpmInvocation(['run', 'demo:echo']),
|
||||||
args: ['run', 'demo:echo'],
|
|
||||||
input: 'echo ci smoke\n',
|
input: 'echo ci smoke\n',
|
||||||
...dependencyOptions,
|
...dependencyOptions,
|
||||||
verify: async (result) => {
|
verify: async (result) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user