Skip to content

Commit 9e120ca

Browse files
committed
fixup! Add mirror option
1 parent 36b68aa commit 9e120ca

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ inputs:
88
node-version:
99
description: 'Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0'
1010
default: '10.x'
11+
node-mirror:
12+
description: 'Use a mirror of node binaries.'
13+
default: 'https://nodejs.org/dist'
1114
registry-url:
1215
description: 'Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN'
1316
scope:

dist/index.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12295,27 +12295,40 @@ function queryLatestMatch(versionSpec, mirror) {
1229512295
nodeVersions.forEach((nodeVersion) => {
1229612296
// ensure this version supports your os and platform
1229712297
if (nodeVersion.files.indexOf(dataFileName) >= 0) {
12298-
versions.push(nodeVersion.version);
12298+
versions.push(nodeVersion);
1229912299
}
1230012300
});
1230112301
// get the latest version that matches the version spec
1230212302
let version = evaluateVersions(versions, versionSpec);
1230312303
return version;
1230412304
});
1230512305
}
12306+
exports.queryLatestMatch = queryLatestMatch;
1230612307
// TODO - should we just export this from @actions/tool-cache? Lifted directly from there
1230712308
function evaluateVersions(versions, versionSpec) {
1230812309
let version = '';
1230912310
core.debug(`evaluating ${versions.length} versions`);
1231012311
versions = versions.sort((a, b) => {
12311-
if (semver.gt(a, b)) {
12312+
const versionA = semver.coerce(a.version);
12313+
const versionB = semver.coerce(b.version);
12314+
// If versions are equal, compare date instead
12315+
if (versionA === versionB || versionA === null || versionB === null) {
12316+
if (new Date(a.date) > new Date(b.date)) {
12317+
return 1;
12318+
}
12319+
return -1;
12320+
}
12321+
if (semver.gt(versionA, versionB)) {
1231212322
return 1;
1231312323
}
1231412324
return -1;
1231512325
});
1231612326
for (let i = versions.length - 1; i >= 0; i--) {
12317-
const potential = versions[i];
12318-
const satisfied = semver.satisfies(potential, versionSpec);
12327+
const potential = versions[i].version;
12328+
const semverPotential = semver.coerce(potential);
12329+
if (semverPotential === null)
12330+
continue;
12331+
const satisfied = semver.satisfies(semverPotential, versionSpec);
1231912332
if (satisfied) {
1232012333
version = potential;
1232112334
break;

0 commit comments

Comments
 (0)