mirror of
				https://github.com/actions/setup-node.git
				synced 2025-11-04 01:03:33 +00:00 
			
		
		
		
	fix: add found cached toolpath to PATH before executing node
This commit is contained in:
		
							parent
							
								
									df568f01a8
								
							
						
					
					
						commit
						c4d0bc7f39
					
				@ -225,7 +225,7 @@ describe('setup-node', () => {
 | 
			
		||||
    await main.run();
 | 
			
		||||
 | 
			
		||||
    expect(logSpy).toHaveBeenCalledWith(
 | 
			
		||||
      `Found v14.0.0 in cache @ ${toolPath} but it does not satisfy the requested version (12.16.2)`
 | 
			
		||||
      `Found v14.0.0 in cache @ ${expPath} but it does not satisfy the requested version (12.16.2)`
 | 
			
		||||
    );
 | 
			
		||||
    expect(logSpy).toHaveBeenCalledWith(
 | 
			
		||||
      `Attempting to download ${versionSpec}...`
 | 
			
		||||
 | 
			
		||||
@ -82,18 +82,25 @@ export async function getNode(
 | 
			
		||||
  if (toolPath) {
 | 
			
		||||
    core.info(`Found in cache @ ${toolPath}`);
 | 
			
		||||
 | 
			
		||||
    if (osPlat != 'win32') {
 | 
			
		||||
      toolPath = path.join(toolPath, 'bin');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    core.addPath(toolPath);
 | 
			
		||||
 | 
			
		||||
    const {stdout: installedVersion} = await exec.getExecOutput(
 | 
			
		||||
      'node',
 | 
			
		||||
      ['--version'],
 | 
			
		||||
      {ignoreReturnCode: true}
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    if (!semver.satisfies(installedVersion, versionSpec)) {
 | 
			
		||||
      core.info(
 | 
			
		||||
        `Found ${installedVersion} in cache @ ${toolPath} but it does not satisfy the requested version (${versionSpec})`
 | 
			
		||||
      );
 | 
			
		||||
      toolPath = '';
 | 
			
		||||
    if (semver.satisfies(installedVersion, versionSpec)) {
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    core.info(
 | 
			
		||||
      `Found ${installedVersion} in cache @ ${toolPath} but it does not satisfy the requested version (${versionSpec})`
 | 
			
		||||
    );
 | 
			
		||||
    toolPath = '';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (!toolPath) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user