mirror of
				https://github.com/actions/setup-node.git
				synced 2025-11-04 08:33:33 +00:00 
			
		
		
		
	Merge 5a3778b347383a5aeec7494a5eeb7602b8bc8ee9 into 2a814b57e1a920a0c910a1007b50142423386ff0
This commit is contained in:
		
						commit
						45e87561cc
					
				@ -17,7 +17,7 @@ export async function run() {
 | 
				
			|||||||
    const cacheLock = core.getInput('cache');
 | 
					    const cacheLock = core.getInput('cache');
 | 
				
			||||||
    await cachePackages(cacheLock);
 | 
					    await cachePackages(cacheLock);
 | 
				
			||||||
  } catch (error) {
 | 
					  } catch (error) {
 | 
				
			||||||
    core.setFailed(error.message);
 | 
					    core.setFailed((error as Error).message);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -47,17 +47,35 @@ export const getCommandOutput = async (toolCommand: string) => {
 | 
				
			|||||||
  return stdout.trim();
 | 
					  return stdout.trim();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const resolvePackageManagerVersionInput = (
 | 
				
			||||||
 | 
					  packageManager: string
 | 
				
			||||||
 | 
					): string | undefined => {
 | 
				
			||||||
 | 
					  let version = core.getInput(`${packageManager}-version`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (version !== '') {
 | 
				
			||||||
 | 
					    core.info(`Using ${packageManager} with version ${version}.`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return version;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const getPackageManagerVersion = async (
 | 
					const getPackageManagerVersion = async (
 | 
				
			||||||
  packageManager: string,
 | 
					  packageManager: string,
 | 
				
			||||||
  command: string
 | 
					  command: string
 | 
				
			||||||
) => {
 | 
					) => {
 | 
				
			||||||
  const stdOut = await getCommandOutput(`${packageManager} ${command}`);
 | 
					  let packageManagerVersion = resolvePackageManagerVersionInput(packageManager);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!stdOut) {
 | 
					  if (packageManagerVersion) {
 | 
				
			||||||
    throw new Error(`Could not retrieve version of ${packageManager}`);
 | 
					    return packageManagerVersion;
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    const stdOut = await getCommandOutput(`${packageManager} ${command}`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!stdOut) {
 | 
				
			||||||
 | 
					      throw new Error(`Could not retrieve version of ${packageManager}`);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return stdOut;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					 | 
				
			||||||
  return stdOut;
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const getPackageManagerInfo = async (packageManager: string) => {
 | 
					export const getPackageManagerInfo = async (packageManager: string) => {
 | 
				
			||||||
 | 
				
			|||||||
@ -116,9 +116,9 @@ export async function getNode(
 | 
				
			|||||||
          `Received HTTP status code ${err.httpStatusCode}.  This usually indicates the rate limit has been exceeded`
 | 
					          `Received HTTP status code ${err.httpStatusCode}.  This usually indicates the rate limit has been exceeded`
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        core.info(err.message);
 | 
					        core.info((err as Error).message);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      core.debug(err.stack);
 | 
					      core.debug((err as Error).stack!);
 | 
				
			||||||
      core.info('Falling back to download directly from Node');
 | 
					      core.info('Falling back to download directly from Node');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -334,7 +334,7 @@ async function resolveVersionFromManifest(
 | 
				
			|||||||
    return info?.resolvedVersion;
 | 
					    return info?.resolvedVersion;
 | 
				
			||||||
  } catch (err) {
 | 
					  } catch (err) {
 | 
				
			||||||
    core.info('Unable to resolve version from manifest...');
 | 
					    core.info('Unable to resolve version from manifest...');
 | 
				
			||||||
    core.debug(err.message);
 | 
					    core.debug((err as Error).message);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -72,7 +72,7 @@ export async function run() {
 | 
				
			|||||||
      `##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`
 | 
					      `##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
  } catch (err) {
 | 
					  } catch (err) {
 | 
				
			||||||
    core.setFailed(err.message);
 | 
					    core.setFailed((err as Error).message);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user