Conversation
|
Ping @jsonperl. Just checking if this PR make sense. |
| XRANGELOOSE = /^#{GTLT.source}\s*#{XRANGEPLAINLOOSE.source}$/.freeze | ||
| COMPARATOR = /^#{GTLT.source}\s*(#{FULLPLAIN.source})$|^$/.freeze | ||
| COMPARATORLOOSE = /^#{GTLT.source}\s*(#{LOOSEPLAIN.source})$|^$/.freeze | ||
| GTE0 = /^\s*>=\s*0\.0\.0\s*$/.freeze |
There was a problem hiding this comment.
GTE0 consts added
|
|
||
| def self.ltr?(version, range, loose: false, platform: nil) | ||
| outside?(version, range, '<', loose: loose, platform: platform) | ||
| def self.ltr?(version, range, loose: false, platform: nil, include_prerelease: false) |
There was a problem hiding this comment.
This copy-pasting of options sucks, but I like it validates argument names 🤔
|
|
||
| raise InvalidRange.new(range) if @set.empty? || @set == [[]] | ||
|
|
||
| if @set.any? |
There was a problem hiding this comment.
All these changes are copied behaviour from node-semver
| ['<=2.0.0', '<=2.0.0'], | ||
| ['<=2.0.0', '<=2.0.0'], | ||
| ['<2.0.0', '<2.0.0'], | ||
| ['1', '>=1.0.0 <2.0.0-0'], |
There was a problem hiding this comment.
Copied test cases from node-semver too.
|
|
||
| raise InvalidRange.new(range) if @set.empty? || @set == [[]] | ||
|
|
||
| if @set.any? |
There was a problem hiding this comment.
We shouldn't be able to get here since line 21 checks the set right?
| raise InvalidRange.new(range) if @set.empty? || @set == [[]] | ||
|
|
||
| if @set.any? | ||
| first = set.first |
There was a problem hiding this comment.
| first = set.first | |
| first = @set.first |
| @set = @set.reject { |c| is_null_set(c[0]) } | ||
| if @set.empty? | ||
| @set = [first] | ||
| elsif @set.any? |
There was a problem hiding this comment.
| elsif @set.any? | |
| else |
| ['>=*', '*'], | ||
| ['', '*'], | ||
| ['*', '*'], | ||
| ['*', '*'], |
| ['~>1', '>=1.0.0 <2.0.0'], | ||
| ['~> 1', '>=1.0.0 <2.0.0'], | ||
| ['~>3.2.1', '>=3.2.1 <3.3.0-0'], | ||
| ['~1', '>=1.0.0 <2.0.0-0'], |
There was a problem hiding this comment.
It looks like some of the stuff above was duplicated, but some test cases here are changed. I'd feel more comfortable if the cases were in addition to the existing ones (obviously removing dupes is fine).
There was a problem hiding this comment.
@jsonperl As I understand, the existing ones were created in a similar way: copied from node-semver. I assume copy-paste-replace is the only way to keep them in sync with node-semver 🙄
| expect(SemanticRange.ltr?('1.0.0-beta', '^1.0.0-alpha')).to eq(false) | ||
| expect(SemanticRange.ltr?('1.0.0-beta', '~1.0.0-alpha')).to eq(false) | ||
| expect(SemanticRange.ltr?('1.0.0', '=0.1.0')).to eq(false) | ||
| [['~ 1.0', '1.1.0'], |
There was a problem hiding this comment.
This is pretty tough to grok the changes on, maybe do the cleanup and changes as separate commits?
Notes: