-
Notifications
You must be signed in to change notification settings - Fork 177
fix #648 #709
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
fix #648 #709
Conversation
🦋 Changeset detectedLatest commit: 8e31e84 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
|
Oops, i was about to merge and i noticed an issue @khuezy PTAL |
| if (major1 !== major2) return major1 - major2; | ||
| if (minor1 !== minor2) return minor1 - minor2; | ||
| return patch1 - patch2; | ||
| return (patch1 ?? 0) - (patch2 ?? 0); |
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.
don't you have the same issue with minor?
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.
Technically we could have this issue for minor2 only.
We only use this to compare with next version, and the next version comes from next/package.json (so should always contain major, minor and patch)
v2 is the one we provide to test, i don't see in which scenario we'd use latest
I should add a comment above the function so that we know about its limitation and how it should be used
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.
The function assumes that M, m, p exists.
const [major1 = 0, minor1 = 0, patch1 = 0] = v1.split(".").map(Number);
const [major2 = 0, minor2 = 0, patch2 = 0] = v2.split(".").map(Number);
This should default those values.
|
Not sure if important but: if (v1 === "latest") return 1;
// ->
if (v1 === "latest") {
return v2 === "latest" ? 0 : 1;
} |
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.
LGTM thanks!
| * Compare two semver versions. | ||
| * @param v1 - First version. Can be "latest", otherwise it should be a valid semver version in the format of `major.minor.patch`. Usually is the next version from the package.json without canary suffix. If minor or patch are missing, they are considered 0. | ||
| * @param v2 - Second version. Should not be "latest", it should be a valid semver version in the format of `major.minor.patch`. If minor or patch are missing, they are considered 0. | ||
| * @see |
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 can't see anything :)
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.
LGTM!
Thought.
When I see
buildHelper.compareSemver(options.nextVersion, "14.1") >= 0;I always think that there would be a nicer way:
buildHelper.compareSemver(options.nextVersion, ">=", 14.1);Co-authored-by: Victor Berchet <[email protected]>
I guess we could refactor it later, i'll merge it for now |
fix #648