-
Notifications
You must be signed in to change notification settings - Fork 984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(iOS) Added Semver to version comparison checks. #695
Merged
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
81f6b1c
Allowed extra variation in version comparison
mattmilan-dev bfc92d5
Update versions.js
mattmilan-dev 1d71673
Add semver support to version comparison
1603bb9
Bug fix (forgot to remove !)
mattmilan-dev f022350
Equal versions perform check favouring non-prerelease
mattmilan-dev 712f803
Update unit test
dcec805
Merge remote-tracking branch 'origin/master'
4244ea3
Removes EOL whitespace for ES Lint
d64f9ad
Remove package-lock.json which sneaked itself in
raphinesse ef20545
Update method and unit test
20429ea
Fix versions.compareVersions to be more forgiving
raphinesse 5742b74
Add unit tests for versions.compareVersions
raphinesse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
semver.coerce
drops labels.When
cleanV1
andcleanV2
is equal, do you think it's worth checking the originalversion
variables and determine if one has a prerelease label, then return the appropriate integer?e.g.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes a lot of sense to do that actually. I've used
.includes
as a formality to make the code easier to read, as the performance loss is minimal in comparison toindexOf
. However, if we need backwards compatibility with < IE 11 (As it's a CLI tool i'm assuming this isn't necessary), i'll go with theindexOf
instead!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use
.includes
, as long as it's supported in Node 6. If not, then this patch needs to wait until we drop support for node 6, which will likely come in next major release.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our JSDocs say "Compares two semver-notated version strings". So in my opinion, this whole function could (and should) be implemented as follows:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize this but
semver
actually does handling comparing prerelease labels, so my suggestion is just doing the work over again.We also don't need to use
coerce
.Exporting
semver.compare
directly will change whatcompareVersions
will return as an error, if it does receive an invalid semver, which will need to refactored in the unit tests but I think that's fine.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the expectation in the unit test will have to be adapted for the new error