From 8c66f89aefe59190295a477c99b61493eb25cd8b Mon Sep 17 00:00:00 2001 From: panticmilos Date: Thu, 19 May 2022 16:48:16 +0200 Subject: [PATCH] improve latest version syntax --- dist/setup/index.js | 10 ++++------ package-lock.json | 2 +- package.json | 2 +- src/installer.ts | 14 +++++--------- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index ecf99914..23e5d16c 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -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) { diff --git a/package-lock.json b/package-lock.json index 87480e4a..dbadde06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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" } diff --git a/package.json b/package.json index 63b36edd..df56518d 100644 --- a/package.json +++ b/package.json @@ -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" } diff --git a/src/installer.ts b/src/installer.ts index 5b87d29a..fb35d73f 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -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) {