Skip to content

[BUG] inc premajor, preminor, and prepatch do the wrong thing if the version is already a pre-release. #751

Open
@wraithgar

Description

@wraithgar

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

From the docs:

premajor in one call will bump the version up to the next major version and down to a prerelease of that major version. preminor, and prepatch work the same way.

If we do these steps in isolation (using the internal, "pre" that does the down to a prerelease) we get:

> semver.inc('2.0.0-pre', 'major')
'2.0.0'
> semver.inc('2.0.0', 'pre')
'2.0.0-0'

But if we do premajor

> semver.inc('2.0.0-pre', 'premajor')
'3.0.0-0'

Expected Behavior

premajor et al should "do what it says on the tin", and not jump an extra major/minor/patch.

Steps To Reproduce

No response

Environment

semver@7.6.3

Metadata

Metadata

Assignees

Labels

Bugthing that needs fixingNeeds Discussionis pending a discussionNeeds Triageneeds an initial review

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions