mirror of
				https://github.com/pnpm/action-setup.git
				synced 2025-10-31 17:32:24 +08:00 
			
		
		
		
	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:
		| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user