The pnpm home directory should be added to PATH and PNPM_HOME

This change is needed to make the action compatible with pnpm v7.

Related breaking change in pnpm: pnpm/pnpm#4280
This commit is contained in:
Zoltan Kochan 2022-02-07 23:15:44 +02:00
parent 15569a497d
commit 6ff6e97bc6
No known key found for this signature in database
GPG key ID: 649E4D4AF74E7DEC
4 changed files with 497 additions and 512 deletions

View file

@ -1,3 +1,4 @@
import * as core from '@actions/core'
import { spawn } from 'child_process'
import { execPath } from 'process'
import { join } from 'path'
@ -22,10 +23,19 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
const response = await fetch('https://pnpm.js.org/pnpm.js')
response.body.pipe(cp.stdin)
return new Promise((resolve, reject) => {
const exitCode = await new Promise<number>((resolve, reject) => {
cp.on('error', reject)
cp.on('close', resolve)
})
if (exitCode === 0) {
const pnpmHome = join(dest, 'node_modules/.bin')
core.addPath(pnpmHome)
// This environment variable will be available in future steps as PNPM_HOME
// It is written as PNPM_HOME_PATH due to a convention in GitHub actions:
// > Any new environment variables you set that point to a location on the filesystem should have a _PATH suffix.
core.exportVariable('PNPM_HOME_PATH', pnpmHome)
}
return exitCode
}
export default runSelfInstaller