From d476296f03a914de2515b9099839c509e4d60bbd Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: May 02 2018 23:52:14 +0000 Subject: fix version comparators with a space after the operator Such as '>= 0.10'. --- diff --git a/nodejs.req b/nodejs.req index 04e1365..52b33f7 100755 --- a/nodejs.req +++ b/nodejs.req @@ -220,9 +220,8 @@ def convert_dep(req, version): # For each comparator in the set, narrow the range to match it, # using the two helper functions. - for comparator in version.split(): - operator, v = re.match(r'(<=|>=|<|>|=|\^|~)?(.*)', comparator).groups() - if operator is None: + for operator, v in re.findall(r'(<=|>=|<|>|=|\^|~)?\s*(\S+)\s*', version): + if not operator: operator = '=' parts = parse_version(v) diff --git a/test/unbundled/nodejs.req.out.exp b/test/unbundled/nodejs.req.out.exp index f2f6f0a..08aeab1 100644 --- a/test/unbundled/nodejs.req.out.exp +++ b/test/unbundled/nodejs.req.out.exp @@ -68,5 +68,7 @@ npm(test709) < 0.1 npm(test710) < 0.1 npm(test711) < 1 npm(test712) < 1 +npm(test750) >= 0.10 +(npm(test751) >= 0.10 with npm(test751) <= 6) (npm(test800) > 1.2 with npm(test800) < 1.9) npm(test900) diff --git a/test/unbundled/package.json.in b/test/unbundled/package.json.in index 68dfc45..4d9624e 100644 --- a/test/unbundled/package.json.in +++ b/test/unbundled/package.json.in @@ -88,6 +88,11 @@ "test711": "^0.x", "test712": "^0", + // Space after the operator + // (the grammar does not permit this, but it is accepted in practice) + "test750": ">= 0.10", + "test751": ">= 0.10 <= 6", + // More than two comparators in a set // (no reason for this to ever appear, but it is permitted) "test800": ">1.2 <2.0 <1.9",