mirror of
https://github.com/actions/setup-node.git
synced 2025-07-04 00:24:58 +00:00
fix toolcache
This commit is contained in:
parent
e7c919e11c
commit
60732b4966
3 changed files with 34 additions and 4 deletions
|
@ -83,7 +83,15 @@ export async function getNode(
|
|||
// check cache
|
||||
core.debug('check toolcache');
|
||||
let toolPath: string;
|
||||
toolPath = tc.find('node', versionSpec, osArch);
|
||||
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…
Add table
Add a link
Reference in a new issue