node-semver icon indicating copy to clipboard operation
node-semver copied to clipboard

[ENHANCMENT] Add explicit "release" identifier to `inc` function to strip prerelease suffix from the version.

Open deej-io opened this issue 6 months ago • 5 comments

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 the patch identifier in that it does not bump the patch version in the case where there is no prerelease suffix.

Instead, this identifier could either:

  • Emit an error that the the current version is not a pre-release; or
  • Return the version unmodified

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.

deej-io avatar Aug 20 '24 14:08 deej-io