Skip to content

Commit 8c66f89

Browse files
committed
improve latest version syntax
1 parent 3601f2a commit 8c66f89

File tree

4 files changed

+11
-17
lines changed

4 files changed

+11
-17
lines changed

dist/setup/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62362,6 +62362,10 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) {
6236262362
core.info(`Failed to resolve version ${versionSpec} from manifest`);
6236362363
}
6236462364
}
62365+
if (['current', 'latest', 'node'].includes(versionSpec)) {
62366+
versionSpec = yield queryDistForMatch(versionSpec, arch);
62367+
core.info(`getting latest node version...`);
62368+
}
6236562369
// check cache
6236662370
let toolPath;
6236762371
toolPath = tc.find('node', versionSpec, osArch);
@@ -62587,12 +62591,6 @@ function queryDistForMatch(versionSpec, arch = os.arch()) {
6258762591
}
6258862592
let versions = [];
6258962593
let nodeVersions = yield getVersionsFromDist();
62590-
if (versionSpec === 'current' ||
62591-
versionSpec === 'latest' ||
62592-
versionSpec === 'node') {
62593-
core.info(`getting latest node version...`);
62594-
return nodeVersions[0].version;
62595-
}
6259662594
nodeVersions.forEach((nodeVersion) => {
6259762595
// ensure this version supports your os and platform
6259862596
if (nodeVersion.files.indexOf(dataFileName) >= 0) {

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@zeit/ncc": "^0.21.0",
4141
"jest": "^27.2.5",
4242
"jest-circus": "^27.2.5",
43-
"prettier": "^1.19.1",
43+
"prettier": "1.19.1",
4444
"ts-jest": "^27.0.5",
4545
"typescript": "^3.8.3"
4646
}

src/installer.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ export async function getNode(
6666
}
6767
}
6868

69+
if (['current', 'latest', 'node'].includes(versionSpec)) {
70+
versionSpec = await queryDistForMatch(versionSpec, arch);
71+
core.info(`getting latest node version...`);
72+
}
73+
6974
// check cache
7075
let toolPath: string;
7176
toolPath = tc.find('node', versionSpec, osArch);
@@ -373,15 +378,6 @@ async function queryDistForMatch(
373378
let versions: string[] = [];
374379
let nodeVersions = await getVersionsFromDist();
375380

376-
if (
377-
versionSpec === 'current' ||
378-
versionSpec === 'latest' ||
379-
versionSpec === 'node'
380-
) {
381-
core.info(`getting latest node version...`);
382-
return nodeVersions[0].version;
383-
}
384-
385381
nodeVersions.forEach((nodeVersion: INodeVersion) => {
386382
// ensure this version supports your os and platform
387383
if (nodeVersion.files.indexOf(dataFileName) >= 0) {

0 commit comments

Comments
 (0)