-
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
coerce
drops build and prerelease information
#592
Comments
Hi Tim, indeed, coerce extracts only major, minor, and patch numbers. Anything else is ignored. It does exactly what you describe in your first sentence. Lines 155 to 161 in 36cd334
If minor or patch are missing, they are replaced with |
Interesting, I am curious, what do you think of my "surprising results" ? To me it means that a use case of As a user of Semver, I want to coerce version strings which may not be compatible before I use them with Because this is surprising to me, I think it may be worth mentioning the behaviour in the documentation. There is an example for how it handles What do you think? |
You could propose changing "Longer versions are simply truncated" to "Only major, minor, and patch are taken into consideration. Longer versions are simply truncated". Feel free to create a PR. |
…m#592) Introduces the new coerce option `full`, if set, allowing to preserve pre-release and build parts of a version.
…m#592) Introduces the new coerce option `full`, if set, allowing to preserve pre-release and build parts of a version.
# What / Why Introduces the new coerce option `includePrerelease`, if set, allowing to preserve pre-release and build parts of a version. ## References Fixes #592 Fixes #357 --------- Co-authored-by: madtisa <temp-email-for-oauth-madtisa@gitlab.localhost> Co-authored-by: Gar <wraithgar@github.com>
Hi there 👋
I am currently using
semver.coerce
to coerce semver-like strings into a string which only contains a major, minor, and patch version.The documentation doesn't mention anything about the other things which
semver.parse
may produce (build number, prerelease, etc.)....is it safe for me to depend on this behaviour? Is there a better way to do this?
In addition, I need to coerce a lot of strings missing a patch version:
The reason I am asking is because of somewhat surprising results. While I don't want the current behaviour of
semver
to change, I think if this is too surprising maybe it should. What do you think? 🤔The text was updated successfully, but these errors were encountered: