Skip to content

Commit

Permalink
fix: inc prerelease with numeric preid (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntkme authored Apr 10, 2022
1 parent 4ceca76 commit 802e161
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion classes/semver.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class SemVer {
if (identifier) {
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
if (this.prerelease[0] === identifier) {
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
if (isNaN(this.prerelease[1])) {
this.prerelease = [identifier, 0]
}
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/increments.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,9 @@ module.exports = [
['1.2.0-1', 'minor', '1.2.0', false, 'dev'],
['1.0.0-1', 'major', '1.0.0', 'dev'],
['1.2.3-dev.bar', 'prerelease', '1.2.3-dev.0', false, 'dev'],

['1.2.3-0', 'prerelease', '1.2.3-1.0', false, '1'],
['1.2.3-1.0', 'prerelease', '1.2.3-1.1', false, '1'],
['1.2.3-1.1', 'prerelease', '1.2.3-1.2', false, '1'],
['1.2.3-1.1', 'prerelease', '1.2.3-2.0', false, '2'],
]

0 comments on commit 802e161

Please sign in to comment.