From 30d233850073e3ff61e3611075ceaf61540ae1ac Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Thu, 15 Nov 2018 15:54:50 +0100 Subject: [PATCH] fix(semver): replace operatorless ranges rather than bump --- lib/versioning/semver/range.js | 3 +++ test/versioning/semver.spec.js | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/versioning/semver/range.js b/lib/versioning/semver/range.js index 8adc54a642..05ef352bf8 100644 --- a/lib/versioning/semver/range.js +++ b/lib/versioning/semver/range.js @@ -52,6 +52,9 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) { // Simple range if (rangeStrategy === 'bump') { if (parsedRange.length === 1) { + if (!element.operator) { + return getNewValue(currentValue, 'replace', fromVersion, toVersion); + } if (element.operator === '^') { const split = currentValue.split('.'); if (suffix.length) { diff --git a/test/versioning/semver.spec.js b/test/versioning/semver.spec.js index b2bf43d356..db3017cdb7 100644 --- a/test/versioning/semver.spec.js +++ b/test/versioning/semver.spec.js @@ -86,6 +86,15 @@ describe('semver.getNewValue()', () => { it('bumps naked tilde', () => { expect(semver.getNewValue('~1', 'bump', '1.0.0', '1.1.7')).toEqual('~1'); }); + it('bumps naked major', () => { + expect(semver.getNewValue('5', 'bump', '5.0.0', '5.1.7')).toEqual('5'); + expect(semver.getNewValue('5', 'bump', '5.0.0', '6.1.7')).toEqual('6'); + }); + it('bumps naked minor', () => { + expect(semver.getNewValue('5.0', 'bump', '5.0.0', '5.0.7')).toEqual('5.0'); + expect(semver.getNewValue('5.0', 'bump', '5.0.0', '5.1.7')).toEqual('5.1'); + expect(semver.getNewValue('5.0', 'bump', '5.0.0', '6.1.7')).toEqual('6.1'); + }); it('replaces equals', () => { expect(semver.getNewValue('=1.0.0', 'replace', '1.0.0', '1.1.0')).toEqual( '=1.1.0' -- GitLab