-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: throw on bad version with correct error message #552
Conversation
|
16a021e
to
fd9578b
Compare
c6b0ce1
to
e0d7c01
Compare
Arrays and objects still throw an ambiguous message but is it worth bringing in something like > require('.').diff([], '1.3.2')
Uncaught TypeError: Invalid Version: > require('.').diff({}, '1.3.2')
Uncaught TypeError: Invalid Version: [object Object] vs
> require('.').diff([], '1.3.2')
Uncaught TypeError: Invalid Version: [] > require('.').diff({}, '1.3.2')
Uncaught TypeError: Invalid Version: {} |
Given that code path should only be hit if you're doing something really wrong, I don't see any harm in making the error more readable with |
e0d7c01
to
abdf690
Compare
Oops... This does break something. I am using this library in a react-native project, and since RN does not run in a Node.js environment, its bundler might not recognize the I've just received a failure report, and haven't investigated into it. Update: I installed util for polyfill, and now it is working fine. |
Ah I checked the node version support of it but didn’t realise this was also used in a browser 🙈 |
The parsing logic that is duplicated in SemVer's constructor was also removed. See #541 for previous discussions about not optimizing for invalid SemVer.
With this fix:
v7.4.0
:503a4e52
: