Skip to content
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

[BUG] inc() may produce invalid semver with ReleaseType: prerelease #349

Closed
boxcee opened this issue Nov 11, 2020 · 0 comments · Fixed by #754
Closed

[BUG] inc() may produce invalid semver with ReleaseType: prerelease #349

boxcee opened this issue Nov 11, 2020 · 0 comments · Fixed by #754
Labels
Bug thing that needs fixing

Comments

@boxcee
Copy link

boxcee commented Nov 11, 2020

What / Why

Given an identifier I want to increment a prerelease version.

Current Behavior

Given an 'invalid' identifier, inc() will produce an invalid semver.

Steps to Reproduce

const identifier = 'hotfix/410';
const incremented = inc(parse('0.0.1'), 'prerelease', identifier);
console.log(!!valid(incremented));
// => false

Expected Behavior

The documentation of inc() specifies this:

Return the version incremented by the release type (major, premajor, minor, preminor, patch, prepatch, or prerelease), or null if it's not valid

In the case above inc() is not returning null, even though the resulting version is not a valid semver. Either the documentation needs to be changed to 'or null if the ReleaseType is not valid' or inc() needs to check the validity of the semver before returning it.

@lukekarrys lukekarrys added the Bug thing that needs fixing label Apr 10, 2022
wraithgar pushed a commit that referenced this issue Jan 28, 2025
- Adds a check of the `identifier` parameter for `inc()` when trying to
increase pre-releases. This prevents the creation of an invalid semver.
- Removes side-effects of `inc()` when it is throwing (it was changing
the version)

Closes #349
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants