From 802e16174fe2a704dba16e97891ce36dc4f2ad76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 9 Apr 2022 20:06:20 -0700 Subject: [PATCH] fix: inc prerelease with numeric preid (#380) --- classes/semver.js | 2 +- test/fixtures/increments.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/classes/semver.js b/classes/semver.js index ed81a7ec..af629551 100644 --- a/classes/semver.js +++ b/classes/semver.js @@ -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] } diff --git a/test/fixtures/increments.js b/test/fixtures/increments.js index e214f2ed..6a998b5f 100644 --- a/test/fixtures/increments.js +++ b/test/fixtures/increments.js @@ -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'], ]