diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3bcbf44..bbb7cc2 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -33,7 +33,14 @@ jobs: run: which pnpm; which pnpx - name: 'Test: version' - run: pnpm --version + run: | + actual="$(pnpm --version)" + echo "pnpm version: ${actual}" + if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then + echo "ERROR: pnpm --version did not produce valid output" + exit 1 + fi + shell: bash - name: 'Test: install in a fresh project' run: | @@ -71,7 +78,14 @@ jobs: run: which pnpm && which pnpx - name: 'Test: version' - run: pnpm --version + run: | + actual="$(pnpm --version)" + echo "pnpm version: ${actual}" + if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then + echo "ERROR: pnpm --version did not produce valid output" + exit 1 + fi + shell: bash test_standalone: name: Test with standalone @@ -98,7 +112,14 @@ jobs: run: which pnpm - name: 'Test: version' - run: pnpm --version + run: | + actual="$(pnpm --version)" + echo "pnpm version: ${actual}" + if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then + echo "ERROR: pnpm --version did not produce valid output" + exit 1 + fi + shell: bash - name: 'Test: install in a fresh project' run: | @@ -196,4 +217,11 @@ jobs: run: which pnpm; which pnpx - name: 'Test: version' - run: pnpm --version + run: | + actual="$(pnpm --version)" + echo "pnpm version: ${actual}" + if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then + echo "ERROR: pnpm --version did not produce valid output" + exit 1 + fi + shell: bash diff --git a/dist/index.js b/dist/index.js index 26f9903..5d098bc 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 c4a484a..1a847af 100644 --- a/src/install-pnpm/run.ts +++ b/src/install-pnpm/run.ts @@ -34,23 +34,33 @@ export async function runSelfInstaller(inputs: Inputs): Promise { return npmExitCode } - const pnpmHome = path.join(dest, 'node_modules', '.bin') - addPath(pnpmHome) + // On Windows with standalone mode, npm's .bin shims can't properly + // execute the extensionless @pnpm/exe native binaries. Add the + // @pnpm/exe directory directly to PATH so pnpm.exe is found natively. + const pnpmHome = standalone && process.platform === 'win32' + ? path.join(dest, 'node_modules', '@pnpm', 'exe') + : path.join(dest, 'node_modules', '.bin') + // pnpm expects PNPM_HOME/bin in PATH for global binaries (e.g. node + // installed via `pnpm runtime`). Add it first so the next addPath + // (pnpmHome itself, which contains pnpm.exe) has higher precedence. addPath(path.join(pnpmHome, 'bin')) + addPath(pnpmHome) exportVariable('PNPM_HOME', pnpmHome) // Ensure pnpm bin link exists — npm ci sometimes doesn't create it - const pnpmBinLink = path.join(pnpmHome, 'pnpm') - if (!existsSync(pnpmBinLink)) { - await mkdir(pnpmHome, { recursive: true }) - const target = standalone - ? path.join('..', '@pnpm', 'exe', 'pnpm') - : path.join('..', 'pnpm', 'bin', 'pnpm.mjs') - await symlink(target, pnpmBinLink) + if (process.platform !== 'win32') { + const pnpmBinLink = path.join(dest, 'node_modules', '.bin', 'pnpm') + if (!existsSync(pnpmBinLink)) { + await mkdir(path.join(dest, 'node_modules', '.bin'), { recursive: true }) + const target = standalone + ? path.join('..', '@pnpm', 'exe', 'pnpm') + : path.join('..', 'pnpm', 'bin', 'pnpm.mjs') + await symlink(target, pnpmBinLink) + } } const bootstrapPnpm = standalone - ? path.join(dest, 'node_modules', '@pnpm', 'exe', 'pnpm') + ? path.join(dest, 'node_modules', '@pnpm', 'exe', process.platform === 'win32' ? 'pnpm.exe' : 'pnpm') : path.join(dest, 'node_modules', 'pnpm', 'bin', 'pnpm.mjs') // Determine the target version diff --git a/src/outputs/index.ts b/src/outputs/index.ts index e25a6b0..1d64199 100644 --- a/src/outputs/index.ts +++ b/src/outputs/index.ts @@ -1,10 +1,11 @@ -import { setOutput, addPath } from '@actions/core' +import { setOutput } from '@actions/core' import { Inputs } from '../inputs' import { getBinDest } from '../utils' export function setOutputs(inputs: Inputs) { const binDest = getBinDest(inputs) - addPath(binDest) + // NOTE: addPath is already called in installPnpm — do not call it again + // here, as a second addPath would shadow the correct entry on Windows. setOutput('dest', inputs.dest) setOutput('bin_dest', binDest) }