mirror of
				https://gitea.com/actions/setup-node.git
				synced 2025-10-29 15:52:42 +08:00 
			
		
		
		
	Merge remote-tracking branch 'upstream/main'
This commit is contained in:
		| @@ -13,12 +13,12 @@ export interface PackageManagerInfo { | ||||
|  | ||||
| export const supportedPackageManagers: SupportedPackageManagers = { | ||||
|   npm: { | ||||
|     lockFilePatterns: ['package-lock.json', 'yarn.lock'], | ||||
|     lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'], | ||||
|     getCacheFolderCommand: 'npm config get cache' | ||||
|   }, | ||||
|   pnpm: { | ||||
|     lockFilePatterns: ['pnpm-lock.yaml'], | ||||
|     getCacheFolderCommand: 'pnpm store path' | ||||
|     getCacheFolderCommand: 'pnpm store path --silent' | ||||
|   }, | ||||
|   yarn1: { | ||||
|     lockFilePatterns: ['yarn.lock'], | ||||
| @@ -94,7 +94,7 @@ export const getCacheDirectoryPath = async ( | ||||
|  | ||||
|   core.debug(`${packageManager} path is ${stdOut}`); | ||||
|  | ||||
|   return stdOut; | ||||
|   return stdOut.trim(); | ||||
| }; | ||||
|  | ||||
| export function isGhes(): boolean { | ||||
|   | ||||
| @@ -495,17 +495,26 @@ function translateArchToDistUrl(arch: string): string { | ||||
| } | ||||
|  | ||||
| export function parseNodeVersionFile(contents: string): string { | ||||
|   let nodeVersion = contents.trim(); | ||||
|   let nodeVersion: string | undefined; | ||||
|  | ||||
|   if (contents.includes('volta')) { | ||||
|     nodeVersion = JSON.parse(contents).volta.node; | ||||
|   const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m); | ||||
|   nodeVersion = found?.groups?.version; | ||||
|  | ||||
|   if (!nodeVersion) { | ||||
|     try { | ||||
|       // Try parsing the file as an NPM `package.json` | ||||
|       // file. | ||||
|       nodeVersion = JSON.parse(contents).engines?.node; | ||||
|  | ||||
|       if (!nodeVersion) throw new Error(); | ||||
|     } catch (err) { | ||||
|       // In the case of an unknown format, | ||||
|       // return as is and evaluate the version separately. | ||||
|       nodeVersion = contents.trim(); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   if (/^v\d/.test(nodeVersion)) { | ||||
|     nodeVersion = nodeVersion.substring(1); | ||||
|   } | ||||
|  | ||||
|   return nodeVersion; | ||||
|   return nodeVersion as string; | ||||
| } | ||||
|  | ||||
| function isLatestSyntax(versionSpec): boolean { | ||||
|   | ||||
							
								
								
									
										13
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								src/main.ts
									
									
									
									
									
								
							| @@ -1,4 +1,5 @@ | ||||
| import * as core from '@actions/core'; | ||||
| import * as exec from '@actions/exec'; | ||||
| import * as installer from './installer'; | ||||
| import fs from 'fs'; | ||||
| import * as auth from './authutil'; | ||||
| @@ -39,6 +40,18 @@ export async function run() { | ||||
|       await installer.getNode(version, stable, checkLatest, auth, arch); | ||||
|     } | ||||
|  | ||||
|     // Output version of node is being used | ||||
|     try { | ||||
|       const {stdout: installedVersion} = await exec.getExecOutput( | ||||
|         'node', | ||||
|         ['--version'], | ||||
|         {ignoreReturnCode: true, silent: true} | ||||
|       ); | ||||
|       core.setOutput('node-version', installedVersion.trim()); | ||||
|     } catch (err) { | ||||
|       core.setOutput('node-version', ''); | ||||
|     } | ||||
|  | ||||
|     const registryUrl: string = core.getInput('registry-url'); | ||||
|     const alwaysAuth: string = core.getInput('always-auth'); | ||||
|     if (registryUrl) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user