-
Notifications
You must be signed in to change notification settings - Fork 500
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
[ENHANCMENT] Add explicit "release" identifier to inc
function to strip prerelease suffix from the version.
#740
Comments
This seems very discrete and user-friendly. So the idea is that npm could then support One of the biggest lessons I've learned in maintaining npm is that it's always best to be explicit and never guess user intent. With that in mind I'd lean towards throwing if the version does not have a pre-release portion. |
Like this? case 'release':
if (!this.prerelease.length) {
throw new Error('version is not a pre-release')
}
this.prerelease = []
break LGTM 👍 |
That's the overall intention, yeah.
Agreed! Thank you for the feedback :)
Great! I'll get on this when I'm out from work. |
|
yes, |
> (new (require('.').SemVer)('1.0.0')).inc('release')
Uncaught Error: version 1.0.0 is not a prerelease
at SemVer.inc (classes/semver.js:181:17)
> require('.').inc('1.0.0', 'release')
null please remember that |
Draft PR at #752 |
I have been building a release process for one of my projects using npm-version and wanted to promote a prerelease version to a full version and it wasn't immediately obvious how to do that.
After delving into the code, I found that
patch
effectively does what I want, however I think this is confusing and potentially error-prone when running the command in a context where we don't know whether the current version is a pre-release or not - e.g. in a CI job.I think it would be beneficial to have a
release
increment identifier that strips the prerelease suffix from the version. This is different from thepatch
identifier in that it does not bump the patch version in the case where there is no prerelease suffix.Instead, this identifier could either:
I would personally prefer it to return an error, however I am open to reasons why a no-op would be better.
I am happy to implement this and propagate the change up to npm-version.
The text was updated successfully, but these errors were encountered: