mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-06-07 12:41:11 +00:00
remove if
This commit is contained in:
parent
b372056939
commit
b717bf1b71
2 changed files with 22 additions and 32 deletions
|
@ -87,22 +87,20 @@ export const splitVersionSpec = (versionSpec: string): string[] =>
|
|||
|
||||
const createRangePreRelease = (
|
||||
versionSpec: string,
|
||||
preRelease: string = ''
|
||||
distribution: string = ''
|
||||
) => {
|
||||
let range: string | undefined;
|
||||
const [raw, prerelease] = splitVersionSpec(versionSpec);
|
||||
const isValidVersion = semver.valid(raw);
|
||||
const rawVersion = isValidVersion ? raw : semver.coerce(raw);
|
||||
const rawVersion = (isValidVersion ? raw : semver.coerce(raw))!;
|
||||
|
||||
if (rawVersion) {
|
||||
if (`-${prerelease}` !== preRelease) {
|
||||
range = `${rawVersion}${`-${prerelease}`.replace(
|
||||
preRelease,
|
||||
`${preRelease}.`
|
||||
)}`;
|
||||
} else {
|
||||
range = `${semver.validRange(`^${rawVersion}${preRelease}`)}-0`;
|
||||
}
|
||||
if (`-${prerelease}` !== distribution) {
|
||||
range = `${rawVersion}${`-${prerelease}`.replace(
|
||||
distribution,
|
||||
`${distribution}.`
|
||||
)}`;
|
||||
} else {
|
||||
range = `${semver.validRange(`^${rawVersion}${distribution}`)}-0`;
|
||||
}
|
||||
|
||||
return {range, includePrerelease: !isValidVersion};
|
||||
|
@ -111,19 +109,13 @@ const createRangePreRelease = (
|
|||
export function versionMatcherFactory(versionSpec: string): VersionMatcher {
|
||||
const raw = splitVersionSpec(versionSpec)[0];
|
||||
const validVersion = semver.valid(raw) ? raw : semver.coerce(raw)?.version;
|
||||
const distribution = distributionOf(versionSpec);
|
||||
|
||||
if (validVersion) {
|
||||
switch (distributionOf(versionSpec)) {
|
||||
switch (distribution) {
|
||||
case Distributions.CANARY:
|
||||
return nightlyV8MatcherFactory(
|
||||
versionSpec,
|
||||
Distributions.CANARY
|
||||
);
|
||||
case Distributions.NIGHTLY:
|
||||
return nightlyV8MatcherFactory(
|
||||
versionSpec,
|
||||
Distributions.NIGHTLY
|
||||
);
|
||||
return nightlyV8MatcherFactory(versionSpec, distribution);
|
||||
case Distributions.RC:
|
||||
case Distributions.DEFAULT:
|
||||
return semverVersionMatcherFactory(versionSpec);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue