Skip to content
Snippets Groups Projects
Commit 30d23385 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

fix(semver): replace operatorless ranges rather than bump

parent 7d31af5e
No related branches found
No related tags found
No related merge requests found
......@@ -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) {
......
......@@ -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'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment