diff --git a/dist/index.js b/dist/index.js index 5ea74e3..453a9a6 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/src/install-pnpm/run.ts b/src/install-pnpm/run.ts index d611dcf..e22ee79 100644 --- a/src/install-pnpm/run.ts +++ b/src/install-pnpm/run.ts @@ -29,16 +29,17 @@ export async function runSelfInstaller(inputs: Inputs): Promise { await writeFile(path.join(dest, 'package.json'), packageJson) await writeFile(path.join(dest, 'package-lock.json'), JSON.stringify(lockfile)) - // npm is co-located with the action's node binary; resolve it directly - // so it works on runners (e.g. GHE self-hosted) where npm is not on PATH. - // PATH still needs node on it for npm's `#!/usr/bin/env node` shebang. + // Prepend the action's node directory to PATH so npm's + // `#!/usr/bin/env node` shebang resolves on runners (e.g. GHE + // self-hosted) where node isn't already on PATH. npm itself is + // resolved via PATH — on the GitHub Actions runner it is not + // co-located with `process.execPath`. const nodeDir = path.dirname(process.execPath) - const npmPath = path.join(nodeDir, process.platform === 'win32' ? 'npm.cmd' : 'npm') // On Windows, the PATH key casing varies; search case-insensitively. const pathKey = Object.keys(process.env).find(k => k.toUpperCase() === 'PATH') ?? 'PATH' const currentPath = process.env[pathKey] const npmEnv = { ...process.env, [pathKey]: currentPath ? nodeDir + path.delimiter + currentPath : nodeDir } - const npmExitCode = await runCommand(npmPath, ['ci'], { cwd: dest, env: npmEnv }) + const npmExitCode = await runCommand('npm', ['ci'], { cwd: dest, env: npmEnv }) if (npmExitCode !== 0) { return npmExitCode }