mirror of
https://github.com/actions/setup-node.git
synced 2025-04-24 04:20:49 +00:00
remove if
This commit is contained in:
parent
b372056939
commit
b717bf1b71
2 changed files with 22 additions and 32 deletions
22
dist/setup/index.js
vendored
22
dist/setup/index.js
vendored
|
@ -73245,18 +73245,16 @@ exports.nightlyV8MatcherFactory = (version, distribution) => {
|
||||||
return matcher;
|
return matcher;
|
||||||
};
|
};
|
||||||
exports.splitVersionSpec = (versionSpec) => versionSpec.split(/-(.*)/s);
|
exports.splitVersionSpec = (versionSpec) => versionSpec.split(/-(.*)/s);
|
||||||
const createRangePreRelease = (versionSpec, preRelease = '') => {
|
const createRangePreRelease = (versionSpec, distribution = '') => {
|
||||||
let range;
|
let range;
|
||||||
const [raw, prerelease] = exports.splitVersionSpec(versionSpec);
|
const [raw, prerelease] = exports.splitVersionSpec(versionSpec);
|
||||||
const isValidVersion = semver.valid(raw);
|
const isValidVersion = semver.valid(raw);
|
||||||
const rawVersion = isValidVersion ? raw : semver.coerce(raw);
|
const rawVersion = (isValidVersion ? raw : semver.coerce(raw));
|
||||||
if (rawVersion) {
|
if (`-${prerelease}` !== distribution) {
|
||||||
if (`-${prerelease}` !== preRelease) {
|
range = `${rawVersion}${`-${prerelease}`.replace(distribution, `${distribution}.`)}`;
|
||||||
range = `${rawVersion}${`-${prerelease}`.replace(preRelease, `${preRelease}.`)}`;
|
}
|
||||||
}
|
else {
|
||||||
else {
|
range = `${semver.validRange(`^${rawVersion}${distribution}`)}-0`;
|
||||||
range = `${semver.validRange(`^${rawVersion}${preRelease}`)}-0`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return { range, includePrerelease: !isValidVersion };
|
return { range, includePrerelease: !isValidVersion };
|
||||||
};
|
};
|
||||||
|
@ -73264,12 +73262,12 @@ function versionMatcherFactory(versionSpec) {
|
||||||
var _a;
|
var _a;
|
||||||
const raw = exports.splitVersionSpec(versionSpec)[0];
|
const raw = exports.splitVersionSpec(versionSpec)[0];
|
||||||
const validVersion = semver.valid(raw) ? raw : (_a = semver.coerce(raw)) === null || _a === void 0 ? void 0 : _a.version;
|
const validVersion = semver.valid(raw) ? raw : (_a = semver.coerce(raw)) === null || _a === void 0 ? void 0 : _a.version;
|
||||||
|
const distribution = exports.distributionOf(versionSpec);
|
||||||
if (validVersion) {
|
if (validVersion) {
|
||||||
switch (exports.distributionOf(versionSpec)) {
|
switch (distribution) {
|
||||||
case Distributions.CANARY:
|
case Distributions.CANARY:
|
||||||
return exports.nightlyV8MatcherFactory(versionSpec, Distributions.CANARY);
|
|
||||||
case Distributions.NIGHTLY:
|
case Distributions.NIGHTLY:
|
||||||
return exports.nightlyV8MatcherFactory(versionSpec, Distributions.NIGHTLY);
|
return exports.nightlyV8MatcherFactory(versionSpec, distribution);
|
||||||
case Distributions.RC:
|
case Distributions.RC:
|
||||||
case Distributions.DEFAULT:
|
case Distributions.DEFAULT:
|
||||||
return exports.semverVersionMatcherFactory(versionSpec);
|
return exports.semverVersionMatcherFactory(versionSpec);
|
||||||
|
|
|
@ -87,22 +87,20 @@ export const splitVersionSpec = (versionSpec: string): string[] =>
|
||||||
|
|
||||||
const createRangePreRelease = (
|
const createRangePreRelease = (
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
preRelease: string = ''
|
distribution: string = ''
|
||||||
) => {
|
) => {
|
||||||
let range: string | undefined;
|
let range: string | undefined;
|
||||||
const [raw, prerelease] = splitVersionSpec(versionSpec);
|
const [raw, prerelease] = splitVersionSpec(versionSpec);
|
||||||
const isValidVersion = semver.valid(raw);
|
const isValidVersion = semver.valid(raw);
|
||||||
const rawVersion = isValidVersion ? raw : semver.coerce(raw);
|
const rawVersion = (isValidVersion ? raw : semver.coerce(raw))!;
|
||||||
|
|
||||||
if (rawVersion) {
|
if (`-${prerelease}` !== distribution) {
|
||||||
if (`-${prerelease}` !== preRelease) {
|
range = `${rawVersion}${`-${prerelease}`.replace(
|
||||||
range = `${rawVersion}${`-${prerelease}`.replace(
|
distribution,
|
||||||
preRelease,
|
`${distribution}.`
|
||||||
`${preRelease}.`
|
)}`;
|
||||||
)}`;
|
} else {
|
||||||
} else {
|
range = `${semver.validRange(`^${rawVersion}${distribution}`)}-0`;
|
||||||
range = `${semver.validRange(`^${rawVersion}${preRelease}`)}-0`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {range, includePrerelease: !isValidVersion};
|
return {range, includePrerelease: !isValidVersion};
|
||||||
|
@ -111,19 +109,13 @@ const createRangePreRelease = (
|
||||||
export function versionMatcherFactory(versionSpec: string): VersionMatcher {
|
export function versionMatcherFactory(versionSpec: string): VersionMatcher {
|
||||||
const raw = splitVersionSpec(versionSpec)[0];
|
const raw = splitVersionSpec(versionSpec)[0];
|
||||||
const validVersion = semver.valid(raw) ? raw : semver.coerce(raw)?.version;
|
const validVersion = semver.valid(raw) ? raw : semver.coerce(raw)?.version;
|
||||||
|
const distribution = distributionOf(versionSpec);
|
||||||
|
|
||||||
if (validVersion) {
|
if (validVersion) {
|
||||||
switch (distributionOf(versionSpec)) {
|
switch (distribution) {
|
||||||
case Distributions.CANARY:
|
case Distributions.CANARY:
|
||||||
return nightlyV8MatcherFactory(
|
|
||||||
versionSpec,
|
|
||||||
Distributions.CANARY
|
|
||||||
);
|
|
||||||
case Distributions.NIGHTLY:
|
case Distributions.NIGHTLY:
|
||||||
return nightlyV8MatcherFactory(
|
return nightlyV8MatcherFactory(versionSpec, distribution);
|
||||||
versionSpec,
|
|
||||||
Distributions.NIGHTLY
|
|
||||||
);
|
|
||||||
case Distributions.RC:
|
case Distributions.RC:
|
||||||
case Distributions.DEFAULT:
|
case Distributions.DEFAULT:
|
||||||
return semverVersionMatcherFactory(versionSpec);
|
return semverVersionMatcherFactory(versionSpec);
|
||||||
|
|
Loading…
Add table
Reference in a new issue