mirror of
https://github.com/actions/setup-node.git
synced 2025-04-23 20:10:48 +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
|
// check cache
|
||||||
core.debug('check toolcache');
|
core.debug('check toolcache');
|
||||||
let toolPath;
|
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 not found in cache, download
|
||||||
if (toolPath) {
|
if (toolPath) {
|
||||||
core.info(`Found in cache @ ${toolPath}`);
|
core.info(`Found in cache @ ${toolPath}`);
|
||||||
|
@ -73322,6 +73328,11 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getNode = getNode;
|
exports.getNode = getNode;
|
||||||
|
function findNightlyVersionInHostedToolcache(versionsSpec, osArch) {
|
||||||
|
const foundAllVersions = tc.findAllVersions('node', osArch);
|
||||||
|
const version = evaluateVersions(foundAllVersions, versionsSpec);
|
||||||
|
return version;
|
||||||
|
}
|
||||||
function isLtsAlias(versionSpec) {
|
function isLtsAlias(versionSpec) {
|
||||||
return versionSpec.startsWith('lts/');
|
return versionSpec.startsWith('lts/');
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,15 @@ export async function getNode(
|
||||||
// check cache
|
// check cache
|
||||||
core.debug('check toolcache');
|
core.debug('check toolcache');
|
||||||
let toolPath: string;
|
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 not found in cache, download
|
||||||
if (toolPath) {
|
if (toolPath) {
|
||||||
|
@ -207,6 +215,16 @@ export async function getNode(
|
||||||
core.addPath(toolPath);
|
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 {
|
function isLtsAlias(versionSpec: string): boolean {
|
||||||
return versionSpec.startsWith('lts/');
|
return versionSpec.startsWith('lts/');
|
||||||
}
|
}
|
||||||
|
@ -398,7 +416,7 @@ function evaluateVersions(versions: string[], versionSpec: string): string {
|
||||||
let version = '';
|
let version = '';
|
||||||
core.debug(`evaluating ${versions.length} versions`);
|
core.debug(`evaluating ${versions.length} versions`);
|
||||||
|
|
||||||
if(versionSpec.includes('nightly')) {
|
if (versionSpec.includes('nightly')) {
|
||||||
return evaluateNightlyVersions(versions, versionSpec);
|
return evaluateNightlyVersions(versions, versionSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,8 @@ export async function run() {
|
||||||
if (version) {
|
if (version) {
|
||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
const auth = !token || isGhes() ? undefined : `token ${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 =
|
const checkLatest =
|
||||||
(core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
|
(core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
|
||||||
await installer.getNode(version, stable, checkLatest, auth, arch);
|
await installer.getNode(version, stable, checkLatest, auth, arch);
|
||||||
|
|
Loading…
Add table
Reference in a new issue