fix: running executable pnpm CLI as a subprocess of pnpm CLI

This commit is contained in:
Zoltan Kochan
2025-03-10 02:42:48 +01:00
parent 0378a9a0ff
commit 0b0bcfa143
2 changed files with 8 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/exec.pnpm-cli-runner": patch
"pnpm": patch
---
Fix running pnpm CLI from pnpm CLI on Windows when the CLI is bundled to an executable.

View File

@@ -6,7 +6,8 @@ export function runPnpmCli (command: string[], { cwd }: { cwd: string }): void {
cwd,
stdio: 'inherit' as const,
}
if (path.basename(process.execPath) === 'pnpm') {
const execFileName = path.basename(process.execPath).toLowerCase()
if (execFileName === 'pnpm' || execFileName === 'pnpm.exe') {
execSync(process.execPath, command, execOpts)
} else if (path.basename(process.argv[1]) === 'pnpm.cjs') {
execSync(process.execPath, [process.argv[1], ...command], execOpts)