mirror of
				https://github.com/actions/setup-node.git
				synced 2025-10-31 16:14:00 +08:00 
			
		
		
		
	refactor: move volta logic
This commit is contained in:
		| @@ -495,7 +495,13 @@ function translateArchToDistUrl(arch: string): string { | ||||
| } | ||||
|  | ||||
| export function parseNodeVersionFile(contents: string): string { | ||||
|   let nodeVersion = contents.trim(); | ||||
|   let nodeVersion; | ||||
|  | ||||
|   if (contents.includes('volta')) { | ||||
|     nodeVersion = JSON.parse(contents).volta.node; | ||||
|   } else { | ||||
|     nodeVersion = contents.trim(); | ||||
|   } | ||||
|  | ||||
|   if (/^v\d/.test(nodeVersion)) { | ||||
|     nodeVersion = nodeVersion.substring(1); | ||||
|   | ||||
							
								
								
									
										14
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/main.ts
									
									
									
									
									
								
							| @@ -65,9 +65,7 @@ export async function run() { | ||||
|  | ||||
| function resolveVersionInput(): string { | ||||
|   let version = core.getInput('node-version'); | ||||
|   const nodeVersionFile = core.getInput('node-version-file'); | ||||
|   const versionFileInput = | ||||
|     nodeVersionFile === 'volta' ? 'package.json' : nodeVersionFile; | ||||
|   const versionFileInput = core.getInput('node-version-file'); | ||||
|  | ||||
|   if (version && versionFileInput) { | ||||
|     core.warning( | ||||
| @@ -91,13 +89,9 @@ function resolveVersionInput(): string { | ||||
|       ); | ||||
|     } | ||||
|  | ||||
|     if (nodeVersionFile === 'volta') { | ||||
|       version = JSON.parse(fs.readFileSync(versionFilePath, 'utf8')).volta.node; | ||||
|     } else { | ||||
|       version = installer.parseNodeVersionFile( | ||||
|         fs.readFileSync(versionFilePath, 'utf8') | ||||
|       ); | ||||
|     } | ||||
|     version = installer.parseNodeVersionFile( | ||||
|       fs.readFileSync(versionFilePath, 'utf8') | ||||
|     ); | ||||
|  | ||||
|     core.info(`Resolved ${versionFileInput} as ${version}`); | ||||
|   } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jef LeCompte
					Jef LeCompte