fixes after rebase

This commit is contained in:
Sergey Dolin 2022-11-22 12:33:08 +01:00
parent f407277148
commit 5f26e47b75

View file

@ -419,31 +419,27 @@ function evaluateNightlyVersions(
} }
// TODO - should we just export this from @actions/tool-cache? Lifted directly from there // TODO - should we just export this from @actions/tool-cache? Lifted directly from there
export function evaluateVersions( export function evaluateVersions(versions: string[], versionSpec: string): string {
versions: string[],
versionSpec: string
): string {
let version = '';
core.debug(`evaluating ${versions.length} versions`); core.debug(`evaluating ${versions.length} versions`);
if (versionSpec.includes('nightly')) { if (versionSpec.includes('nightly')) {
return evaluateNightlyVersions(versions, versionSpec); return evaluateNightlyVersions(versions, versionSpec);
} }
versions = versions.sort(semver.rcompare);
const matcher: (potential: string) => boolean = isVersionCanary(versionSpec) const matcher: (potential: string) => boolean = isVersionCanary(versionSpec)
? evaluateCanaryMatcher(versionSpec) ? evaluateCanaryMatcher(versionSpec)
: potential => semver.satisfies(potential, versionSpec); : potential => semver.satisfies(potential, versionSpec);
for (let i = versions.length - 1; i >= 0; i--) { const version = versions.sort(semver.rcompare).find(matcher) || ''
/*
for (let i = 0; i< versions.length; i++) {
const potential: string = versions[i]; const potential: string = versions[i];
const satisfied: boolean = matcher(potential); const satisfied: boolean = matcher(potential);
if (satisfied) { if (satisfied) {
version = potential; version = potential;
break; break;
} }
} }*/
if (version) { if (version) {
core.debug(`matched: ${version}`); core.debug(`matched: ${version}`);
@ -455,7 +451,7 @@ export function evaluateVersions(
} }
export function getNodejsDistUrl(version: string) { export function getNodejsDistUrl(version: string) {
const prerelease = semver.prerelease(version); const prerelease = semver.prerelease(version) && !isVersionCanary(version);
if (version.includes('nightly')) { if (version.includes('nightly')) {
core.debug('requested nightly distribution'); core.debug('requested nightly distribution');
return 'https://nodejs.org/download/nightly'; return 'https://nodejs.org/download/nightly';