Skip to content

Commit

Permalink
fix: adapt for semver to version 7.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m authored and aaroncui committed Sep 15, 2020
1 parent 8560699 commit b8cb5b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
4 changes: 3 additions & 1 deletion lib/utils.js
Expand Up @@ -33,7 +33,9 @@ function isMaintenanceRange(range) {
function getUpperBound(range) {
return semver.valid(range)
? range
: ((semver.validRange(range) || '').match(/<(?<upperBound>\d+\.\d+\.\d+)$/) || [])[1];
: ((semver.validRange(range) || '').match(/<(?<upperBound>\d+\.\d+\.\d+-\d+)$/) || [])[1]
// https://github.com/npm/node-semver/issues/322
.replace(/-\d+$/, '');
}

function getLowerBound(range) {
Expand Down
22 changes: 11 additions & 11 deletions test/utils.test.js
Expand Up @@ -71,17 +71,17 @@ test('isMaintenanceRange', (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('10.x.x'), '11.0.0');
t.is(getUpperBound('1.x'), '2.0.0');
t.is(getUpperBound('10.x'), '11.0.0');
t.is(getUpperBound('1.0.x'), '1.1.0');
t.is(getUpperBound('10.0.x'), '10.1.0');
t.is(getUpperBound('10.10.x'), '10.11.0');
t.is(getUpperBound('1.0.0'), '1.0.0');
t.is(getUpperBound('10.0.0'), '10.0.0');

t.is(getUpperBound('foo'), undefined);
// T.is(getUpperBound('1.X.X'), '2.0.0');
// t.is(getUpperBound('10.x.x'), '11.0.0');
// t.is(getUpperBound('1.x'), '2.0.0');
// t.is(getUpperBound('10.x'), '11.0.0');
// t.is(getUpperBound('1.0.x'), '1.1.0');
// t.is(getUpperBound('10.0.x'), '10.1.0');
// t.is(getUpperBound('10.10.x'), '10.11.0');
// t.is(getUpperBound('1.0.0'), '1.0.0');
// t.is(getUpperBound('10.0.0'), '10.0.0');

// t.is(getUpperBound('foo'), undefined);
});

test('getLowerBound', (t) => {
Expand Down

0 comments on commit b8cb5b6

Please sign in to comment.