Skip to content

Conversation

ntkme
Copy link
Contributor

@ntkme ntkme commented May 1, 2021

The semver spec says prerelease can be numeric:

<pre-release identifier> ::= <alphanumeric identifier>
                           | <numeric identifier>

This PR fixes inc prerelease with numeric preid.

E.g. inc('1.0.0-1.0', 'prerelease', '1') should return 1.0.0-1.1, but today it returns 1.0.0-1.0.

The bug is that currently it compares preid with this.prerelease[0] === identifier, and a string '1' is not equal to number 1, thus it's returning incorrect result. Change this comparison to use compareIdentifiers just like everywhere else fixes the problem.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 9f91452 on ntkme:fix-prerelease-with-numeric-preid into e79ac3a on npm:master.

@ntkme
Copy link
Contributor Author

ntkme commented Apr 8, 2022

@lukekarrys Sorry for pinging but this PR is a one line bug fix that has been sitting for nearly one year without getting any attention, even though it has been confirmed as a bug in npm/cli#3181. Can you please take a look? Thanks.

@lukekarrys lukekarrys changed the title Fix inc prerelease with numeric preid fix: inc prerelease with numeric preid Apr 9, 2022
@lukekarrys lukekarrys merged commit 802e161 into npm:main Apr 10, 2022
@ntkme ntkme deleted the fix-prerelease-with-numeric-preid branch April 10, 2022 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] npm version prerelease does not work with numeric --preid
3 participants