mirror of
				https://github.com/actions/setup-node.git
				synced 2025-11-04 01:03:33 +00:00 
			
		
		
		
	separate function for resolving version file added
This commit is contained in:
		
							parent
							
								
									96fa061ec2
								
							
						
					
					
						commit
						f927de6ff2
					
				
							
								
								
									
										42
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										42
									
								
								src/main.ts
									
									
									
									
									
								
							@ -13,25 +13,7 @@ export async function run() {
 | 
				
			|||||||
    // Version is optional.  If supplied, install / use from the tool cache
 | 
					    // Version is optional.  If supplied, install / use from the tool cache
 | 
				
			||||||
    // If not supplied then task is still used to setup proxy, auth, etc...
 | 
					    // If not supplied then task is still used to setup proxy, auth, etc...
 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
    let version = core.getInput('node-version');
 | 
					    let version = resolveVersionInput();
 | 
				
			||||||
    if (!version) {
 | 
					 | 
				
			||||||
      version = core.getInput('version');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      if (!version) {
 | 
					 | 
				
			||||||
        const versionFile = core.getInput('node-version-file');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (!!versionFile) {
 | 
					 | 
				
			||||||
          const versionFilePath = path.join(
 | 
					 | 
				
			||||||
            process.env.GITHUB_WORKSPACE!,
 | 
					 | 
				
			||||||
            versionFile
 | 
					 | 
				
			||||||
          );
 | 
					 | 
				
			||||||
          version = installer.parseNodeVersionFile(
 | 
					 | 
				
			||||||
            fs.readFileSync(versionFilePath, 'utf8')
 | 
					 | 
				
			||||||
          );
 | 
					 | 
				
			||||||
          core.info(`Resolved ${versionFile} as ${version}`);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let arch = core.getInput('architecture');
 | 
					    let arch = core.getInput('architecture');
 | 
				
			||||||
    const cache = core.getInput('cache');
 | 
					    const cache = core.getInput('cache');
 | 
				
			||||||
@ -90,3 +72,25 @@ function isGhes(): boolean {
 | 
				
			|||||||
  );
 | 
					  );
 | 
				
			||||||
  return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
 | 
					  return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function resolveVersionInput(): string {
 | 
				
			||||||
 | 
					  let version = core.getInput('node-version') || core.getInput('version');
 | 
				
			||||||
 | 
					  if (version) {
 | 
				
			||||||
 | 
					    return version;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const versionFileInput = core.getInput('node-version-file');
 | 
				
			||||||
 | 
					  if (versionFileInput) {
 | 
				
			||||||
 | 
					    const versionFilePath = path.join(
 | 
				
			||||||
 | 
					            process.env.GITHUB_WORKSPACE!,
 | 
				
			||||||
 | 
					            versionFileInput
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					    version = installer.parseNodeVersionFile(
 | 
				
			||||||
 | 
					            fs.readFileSync(versionFilePath, 'utf8')
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					    core.info(`Resolved ${versionFileInput} as ${version}`);
 | 
				
			||||||
 | 
					    return version;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return null as any;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user