Search code examples
npmsemantic-versioning

How to use npm version to increment the counter behind the prepatch / preid suffix


I'm trying to find out how to correctly use npm version with prepatch (also premajor or preminor) / preid options to increment the counter behind the suffix.

e.g.:

  • I have a v.0.5.22 and want to append -rc
  • I used the command npm version prepatch --preid rc
  • then I get v.0.5.23-rc.0, fine so far.
  • but the next time I'm using the same command I end up with v.0.5.24-rc.0,
  • what I want is to get v.0.5.23-rc.1 instead

How can I only increment the counter behind -rc. and keep the patch number? Or am I misunderstanding the purpose of prepatch / preid?


Solution

  • Alright, I'll answer my own question for future reference.

    After having v.0.5.23-rc.0 the command to only bump the number behind the . has to be:

    npm version prerelease

    Then I would get v.0.5.23-rc.1.