1
0
Fork 0
mirror of https://github.com/actions/setup-node synced 2024-12-22 13:12:43 +00:00

improve latest version syntax

This commit is contained in:
panticmilos 2022-05-19 16:48:16 +02:00
parent 3601f2a33e
commit 8c66f89aef
4 changed files with 11 additions and 17 deletions

10
dist/setup/index.js vendored
View file

@ -62362,6 +62362,10 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) {
core.info(`Failed to resolve version ${versionSpec} from manifest`);
}
}
if (['current', 'latest', 'node'].includes(versionSpec)) {
versionSpec = yield queryDistForMatch(versionSpec, arch);
core.info(`getting latest node version...`);
}
// check cache
let toolPath;
toolPath = tc.find('node', versionSpec, osArch);
@ -62587,12 +62591,6 @@ function queryDistForMatch(versionSpec, arch = os.arch()) {
}
let versions = [];
let nodeVersions = yield getVersionsFromDist();
if (versionSpec === 'current' ||
versionSpec === 'latest' ||
versionSpec === 'node') {
core.info(`getting latest node version...`);
return nodeVersions[0].version;
}
nodeVersions.forEach((nodeVersion) => {
// ensure this version supports your os and platform
if (nodeVersion.files.indexOf(dataFileName) >= 0) {

2
package-lock.json generated
View file

@ -26,7 +26,7 @@
"@zeit/ncc": "^0.21.0",
"jest": "^27.2.5",
"jest-circus": "^27.2.5",
"prettier": "^1.19.1",
"prettier": "1.19.1",
"ts-jest": "^27.0.5",
"typescript": "^3.8.3"
}

View file

@ -40,7 +40,7 @@
"@zeit/ncc": "^0.21.0",
"jest": "^27.2.5",
"jest-circus": "^27.2.5",
"prettier": "^1.19.1",
"prettier": "1.19.1",
"ts-jest": "^27.0.5",
"typescript": "^3.8.3"
}

View file

@ -66,6 +66,11 @@ export async function getNode(
}
}
if (['current', 'latest', 'node'].includes(versionSpec)) {
versionSpec = await queryDistForMatch(versionSpec, arch);
core.info(`getting latest node version...`);
}
// check cache
let toolPath: string;
toolPath = tc.find('node', versionSpec, osArch);
@ -373,15 +378,6 @@ async function queryDistForMatch(
let versions: string[] = [];
let nodeVersions = await getVersionsFromDist();
if (
versionSpec === 'current' ||
versionSpec === 'latest' ||
versionSpec === 'node'
) {
core.info(`getting latest node version...`);
return nodeVersions[0].version;
}
nodeVersions.forEach((nodeVersion: INodeVersion) => {
// ensure this version supports your os and platform
if (nodeVersion.files.indexOf(dataFileName) >= 0) {