remove changing prerelease

This commit is contained in:
Dmitry Shibanov 2022-12-27 20:58:46 +01:00
parent 7f2fa59092
commit 363785e8f4
4 changed files with 29 additions and 128 deletions

View file

@ -1,4 +1,3 @@
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
import semver from 'semver';
@ -33,44 +32,11 @@ export default class NightlyNodejs extends BaseDistribution {
return toolPath;
}
protected evaluateVersions(versions: string[]): string {
let version = '';
core.debug(`evaluating ${versions.length} versions`);
const {includePrerelease, range} = this.createRangePreRelease(
this.nodeInfo.versionSpec
);
for (let i = 0; i < versions.length; i++) {
const potential: string = versions[i];
const satisfied: boolean = semver.satisfies(
potential.replace(this.distribution, `${this.distribution}.`),
range,
{
includePrerelease: includePrerelease
}
);
if (satisfied) {
version = potential;
break;
}
}
if (version) {
core.debug(`matched: ${version}`);
} else {
core.debug('match not found');
}
return version;
}
protected getDistributionUrl(): string {
return 'https://nodejs.org/download/nightly';
}
protected createRangePreRelease(versionSpec: string) {
protected validRange(versionSpec: string) {
let range: string;
const [raw, prerelease] = this.splitVersionSpec(versionSpec);
const isValidVersion = semver.valid(raw);
@ -85,7 +51,7 @@ export default class NightlyNodejs extends BaseDistribution {
range = `${semver.validRange(`^${rawVersion}-${this.distribution}`)}-0`;
}
return {range, includePrerelease: !isValidVersion};
return {range, options: {includePrerelease: !isValidVersion}};
}
protected splitVersionSpec(versionSpec: string) {