mirror of
https://github.com/actions/setup-node.git
synced 2025-04-22 03:28:42 +00:00
fix toolcache
This commit is contained in:
parent
e7c919e11c
commit
60732b4966
3 changed files with 34 additions and 4 deletions
13
dist/setup/index.js
vendored
13
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;
|
||||
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) {
|
||||
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;
|
||||
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
Reference in a new issue