@@ -62343,6 +62343,7 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) {
62343
62343
return __awaiter(this, void 0, void 0, function* () {
62344
62344
// Store manifest data to avoid multiple calls
62345
62345
let manifest;
62346
+ let nodeVersions;
62346
62347
let osPlat = os.platform();
62347
62348
let osArch = translateArchToDistUrl(arch);
62348
62349
if (isLtsAlias(versionSpec)) {
@@ -62351,6 +62352,11 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) {
62351
62352
manifest = yield getManifest(auth);
62352
62353
versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest);
62353
62354
}
62355
+ if (isLatestSyntax(versionSpec)) {
62356
+ nodeVersions = yield getVersionsFromDist();
62357
+ versionSpec = yield queryDistForMatch(versionSpec, arch, nodeVersions);
62358
+ core.info(`getting latest node version...`);
62359
+ }
62354
62360
if (checkLatest) {
62355
62361
core.info('Attempt to resolve the latest version from manifest...');
62356
62362
const resolvedVersion = yield resolveVersionFromManifest(versionSpec, stable, auth, osArch, manifest);
@@ -62402,7 +62408,7 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) {
62402
62408
// Download from nodejs.org
62403
62409
//
62404
62410
if (!downloadPath) {
62405
- info = yield getInfoFromDist(versionSpec, arch);
62411
+ info = yield getInfoFromDist(versionSpec, arch, nodeVersions );
62406
62412
if (!info) {
62407
62413
throw new Error(`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
62408
62414
}
@@ -62502,12 +62508,11 @@ function getInfoFromManifest(versionSpec, stable, auth, osArch = translateArchTo
62502
62508
return info;
62503
62509
});
62504
62510
}
62505
- function getInfoFromDist(versionSpec, arch = os.arch()) {
62511
+ function getInfoFromDist(versionSpec, arch = os.arch(), nodeVersions ) {
62506
62512
return __awaiter(this, void 0, void 0, function* () {
62507
62513
let osPlat = os.platform();
62508
62514
let osArch = translateArchToDistUrl(arch);
62509
- let version;
62510
- version = yield queryDistForMatch(versionSpec, arch);
62515
+ let version = yield queryDistForMatch(versionSpec, arch, nodeVersions);
62511
62516
if (!version) {
62512
62517
return null;
62513
62518
}
@@ -62566,7 +62571,7 @@ function evaluateVersions(versions, versionSpec) {
62566
62571
}
62567
62572
return version;
62568
62573
}
62569
- function queryDistForMatch(versionSpec, arch = os.arch()) {
62574
+ function queryDistForMatch(versionSpec, arch = os.arch(), nodeVersions ) {
62570
62575
return __awaiter(this, void 0, void 0, function* () {
62571
62576
let osPlat = os.platform();
62572
62577
let osArch = translateArchToDistUrl(arch);
@@ -62585,11 +62590,12 @@ function queryDistForMatch(versionSpec, arch = os.arch()) {
62585
62590
default:
62586
62591
throw new Error(`Unexpected OS '${osPlat}'`);
62587
62592
}
62593
+ if (!nodeVersions) {
62594
+ core.debug('No dist manifest cached');
62595
+ nodeVersions = yield getVersionsFromDist();
62596
+ }
62588
62597
let versions = [];
62589
- let nodeVersions = yield getVersionsFromDist();
62590
- if (versionSpec === 'current' ||
62591
- versionSpec === 'latest' ||
62592
- versionSpec === 'node') {
62598
+ if (isLatestSyntax(versionSpec)) {
62593
62599
core.info(`getting latest node version...`);
62594
62600
return nodeVersions[0].version;
62595
62601
}
@@ -62688,6 +62694,9 @@ function parseNodeVersionFile(contents) {
62688
62694
return nodeVersion;
62689
62695
}
62690
62696
exports.parseNodeVersionFile = parseNodeVersionFile;
62697
+ function isLatestSyntax(versionSpec) {
62698
+ return ['current', 'latest', 'node'].includes(versionSpec);
62699
+ }
62691
62700
62692
62701
62693
62702
/***/ }),
0 commit comments