correctly parse '~> 2.0.0'

This commit is contained in:
AJ ONeal 2018-10-08 19:11:40 -06:00
parent 55d71d3929
commit daab053561
3 changed files with 13 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "semver-utils", "name": "semver-utils",
"version": "1.1.2", "version": "1.1.3",
"description": "Tools for manipulating semver strings and objects", "description": "Tools for manipulating semver strings and objects",
"homepage": "https://git.coolaj86.com/coolaj86/semver-utils.js", "homepage": "https://git.coolaj86.com/coolaj86/semver-utils.js",
"main": "semver-utils.js", "main": "semver-utils.js",

View File

@ -8,7 +8,7 @@
// | | | |optional build prefixed by '+' // | | | |optional build prefixed by '+'
var reSemver = /^v?((\d+)\.(\d+)\.(\d+))(?:-([\dA-Za-z\-]+(?:\.[\dA-Za-z\-]+)*))?(?:\+([\dA-Za-z\-]+(?:\.[\dA-Za-z\-]+)*))?$/ var reSemver = /^v?((\d+)\.(\d+)\.(\d+))(?:-([\dA-Za-z\-]+(?:\.[\dA-Za-z\-]+)*))?(?:\+([\dA-Za-z\-]+(?:\.[\dA-Za-z\-]+)*))?$/
//, reSemverRange = /\s*((\|\||\-)|(([<>~]?=?)\s*(v)?([0-9]+)(\.(x|[0-9]+))?(\.(x|[0-9]+))?(([\-+])([a-zA-Z0-9\.]+))?))\s*/g //, reSemverRange = /\s*((\|\||\-)|(([<>~]?=?)\s*(v)?([0-9]+)(\.(x|[0-9]+))?(\.(x|[0-9]+))?(([\-+])([a-zA-Z0-9\.]+))?))\s*/g
, reSemverRange = /\s*((\|\||\-)|(([<>~^]?=?)\s*(v)?([0-9]+)(\.(x|\*|[0-9]+))?(\.(x|\*|[0-9]+))?(([\-+])([a-zA-Z0-9\.-]+))?))\s*/g , reSemverRange = /\s*((\|\||\-)|(([<>~^]*=?)\s*(v)?([0-9]+)(\.(x|\*|[0-9]+))?(\.(x|\*|[0-9]+))?(([\-+])([a-zA-Z0-9\.-]+))?))\s*/g
; ;
// Returns a new object with all of the undefined properties removed from the given object // Returns a new object with all of the undefined properties removed from the given object

View File

@ -189,4 +189,14 @@ describe('parseRange', function() {
}]); }]);
}); });
it('should parse ~> ranges', function() {
deepOwnEqual(semverutils.parseRange('~> 2.0.0'), [{
semver: '~> 2.0.0',
operator: '~>',
major: '2',
minor: '0',
patch: '0'
}]);
});
}); });