fix: adapt for semver to version 7.3.2 (part II) (#1530)
This commit is contained in:
parent
0363790b8a
commit
431d571a7b
11
lib/utils.js
11
lib/utils.js
@ -31,11 +31,14 @@ function isMaintenanceRange(range) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getUpperBound(range) {
|
function getUpperBound(range) {
|
||||||
return semver.valid(range)
|
const result = semver.valid(range)
|
||||||
? range
|
? range
|
||||||
: ((semver.validRange(range) || '').match(/<(?<upperBound>\d+\.\d+\.\d+-\d+)$/) || [])[1]
|
: ((semver.validRange(range) || '').match(/<(?<upperBound>\d+\.\d+\.\d+(-\d+)?)$/) || [])[1];
|
||||||
// https://github.com/npm/node-semver/issues/322
|
|
||||||
.replace(/-\d+$/, '');
|
return result
|
||||||
|
? // https://github.com/npm/node-semver/issues/322
|
||||||
|
result.replace(/-\d+$/, '')
|
||||||
|
: result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLowerBound(range) {
|
function getLowerBound(range) {
|
||||||
|
@ -71,17 +71,17 @@ test('isMaintenanceRange', (t) => {
|
|||||||
|
|
||||||
test('getUpperBound', (t) => {
|
test('getUpperBound', (t) => {
|
||||||
t.is(getUpperBound('1.x.x'), '2.0.0');
|
t.is(getUpperBound('1.x.x'), '2.0.0');
|
||||||
// T.is(getUpperBound('1.X.X'), '2.0.0');
|
t.is(getUpperBound('1.X.X'), '2.0.0');
|
||||||
// t.is(getUpperBound('10.x.x'), '11.0.0');
|
t.is(getUpperBound('10.x.x'), '11.0.0');
|
||||||
// t.is(getUpperBound('1.x'), '2.0.0');
|
t.is(getUpperBound('1.x'), '2.0.0');
|
||||||
// t.is(getUpperBound('10.x'), '11.0.0');
|
t.is(getUpperBound('10.x'), '11.0.0');
|
||||||
// t.is(getUpperBound('1.0.x'), '1.1.0');
|
t.is(getUpperBound('1.0.x'), '1.1.0');
|
||||||
// t.is(getUpperBound('10.0.x'), '10.1.0');
|
t.is(getUpperBound('10.0.x'), '10.1.0');
|
||||||
// t.is(getUpperBound('10.10.x'), '10.11.0');
|
t.is(getUpperBound('10.10.x'), '10.11.0');
|
||||||
// t.is(getUpperBound('1.0.0'), '1.0.0');
|
t.is(getUpperBound('1.0.0'), '1.0.0');
|
||||||
// t.is(getUpperBound('10.0.0'), '10.0.0');
|
t.is(getUpperBound('10.0.0'), '10.0.0');
|
||||||
|
|
||||||
// t.is(getUpperBound('foo'), undefined);
|
t.is(getUpperBound('foo'), undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getLowerBound', (t) => {
|
test('getLowerBound', (t) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user