mirror of
				https://github.com/actions/setup-node.git
				synced 2025-11-04 01:33:33 +00:00 
			
		
		
		
	fix toolcache
This commit is contained in:
		
							parent
							
								
									e7c919e11c
								
							
						
					
					
						commit
						60732b4966
					
				
							
								
								
									
										11
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										11
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							@ -73226,7 +73226,13 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) {
 | 
			
		||||
        // check cache
 | 
			
		||||
        core.debug('check toolcache');
 | 
			
		||||
        let toolPath;
 | 
			
		||||
        if (isNightly) {
 | 
			
		||||
            const nightlyVersion = findNightlyVersionInHostedToolcache(versionSpec, osArch);
 | 
			
		||||
            toolPath = tc.find('node', nightlyVersion, osArch);
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            toolPath = tc.find('node', versionSpec, osArch);
 | 
			
		||||
        }
 | 
			
		||||
        // If not found in cache, download
 | 
			
		||||
        if (toolPath) {
 | 
			
		||||
            core.info(`Found in cache @ ${toolPath}`);
 | 
			
		||||
@ -73322,6 +73328,11 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) {
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.getNode = getNode;
 | 
			
		||||
function findNightlyVersionInHostedToolcache(versionsSpec, osArch) {
 | 
			
		||||
    const foundAllVersions = tc.findAllVersions('node', osArch);
 | 
			
		||||
    const version = evaluateVersions(foundAllVersions, versionsSpec);
 | 
			
		||||
    return version;
 | 
			
		||||
}
 | 
			
		||||
function isLtsAlias(versionSpec) {
 | 
			
		||||
    return versionSpec.startsWith('lts/');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -83,7 +83,15 @@ export async function getNode(
 | 
			
		||||
  // check cache
 | 
			
		||||
  core.debug('check toolcache');
 | 
			
		||||
  let toolPath: string;
 | 
			
		||||
  if (isNightly) {
 | 
			
		||||
    const nightlyVersion = findNightlyVersionInHostedToolcache(
 | 
			
		||||
      versionSpec,
 | 
			
		||||
      osArch
 | 
			
		||||
    );
 | 
			
		||||
    toolPath = tc.find('node', nightlyVersion, osArch);
 | 
			
		||||
  } else {
 | 
			
		||||
    toolPath = tc.find('node', versionSpec, osArch);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // If not found in cache, download
 | 
			
		||||
  if (toolPath) {
 | 
			
		||||
@ -207,6 +215,16 @@ export async function getNode(
 | 
			
		||||
  core.addPath(toolPath);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function findNightlyVersionInHostedToolcache(
 | 
			
		||||
  versionsSpec: string,
 | 
			
		||||
  osArch: string
 | 
			
		||||
) {
 | 
			
		||||
  const foundAllVersions = tc.findAllVersions('node', osArch);
 | 
			
		||||
  const version = evaluateVersions(foundAllVersions, versionsSpec);
 | 
			
		||||
 | 
			
		||||
  return version;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function isLtsAlias(versionSpec: string): boolean {
 | 
			
		||||
  return versionSpec.startsWith('lts/');
 | 
			
		||||
}
 | 
			
		||||
@ -398,7 +416,7 @@ function evaluateVersions(versions: string[], versionSpec: string): string {
 | 
			
		||||
  let version = '';
 | 
			
		||||
  core.debug(`evaluating ${versions.length} versions`);
 | 
			
		||||
 | 
			
		||||
  if(versionSpec.includes('nightly')) {
 | 
			
		||||
  if (versionSpec.includes('nightly')) {
 | 
			
		||||
    return evaluateNightlyVersions(versions, versionSpec);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -34,7 +34,8 @@ export async function run() {
 | 
			
		||||
    if (version) {
 | 
			
		||||
      const token = core.getInput('token');
 | 
			
		||||
      const auth = !token || isGhes() ? undefined : `token ${token}`;
 | 
			
		||||
      const stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
 | 
			
		||||
      const stable =
 | 
			
		||||
        (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
 | 
			
		||||
      const checkLatest =
 | 
			
		||||
        (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
 | 
			
		||||
      await installer.getNode(version, stable, checkLatest, auth, arch);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user