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

fix(semver): handle ~>

parent 78271c81
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,9 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) {
return toVersion;
}
const parsedRange = parseRange(currentValue);
if (currentValue.startsWith('~>')) {
parsedRange[0].operator = '~>';
}
const element = parsedRange[parsedRange.length - 1];
if (rangeStrategy === 'widen') {
const newValue = getNewValue(
......@@ -96,6 +99,9 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) {
);
return null;
}
if (element.operator === '~>') {
return `~> ${toVersionMajor}.${toVersionMinor}.0`;
}
if (element.operator === '^') {
if (suffix.length || !fromVersion) {
return `^${toVersionMajor}.${toVersionMinor}.${toVersionPatch}${suffix}`;
......
......@@ -60,6 +60,11 @@ describe('semver.getNewValue()', () => {
'^1.0.7'
);
});
it('supports tilde greater than', () => {
expect(semver.getNewValue('~> 1.0.0', 'replace', '1.0.0', '1.1.7')).toEqual(
'~> 1.1.0'
);
});
it('bumps short caret to new', () => {
expect(semver.getNewValue('^1.0', 'bump', '1.0.0', '1.1.7')).toEqual(
'^1.1'
......
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