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

fix(composer): lazy evaluate fromVersion major

parent 77d6a29b
No related branches found
No related tags found
No related merge requests found
...@@ -55,7 +55,6 @@ const minSatisfyingVersion = (versions, range) => ...@@ -55,7 +55,6 @@ const minSatisfyingVersion = (versions, range) =>
semver.minSatisfyingVersion(versions.map(composer2npm), composer2npm(range)); semver.minSatisfyingVersion(versions.map(composer2npm), composer2npm(range));
function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) { function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) {
const fromMajor = getMajor(fromVersion);
const toMajor = getMajor(toVersion); const toMajor = getMajor(toVersion);
const toMinor = getMinor(toVersion); const toMinor = getMinor(toVersion);
let newValue; let newValue;
...@@ -84,7 +83,7 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) { ...@@ -84,7 +83,7 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) {
newValue = `~${toMajor}`; newValue = `~${toMajor}`;
} else if (currentValue.match(/^~([0-9]*(?:\.[0-9]*)?)$/)) { } else if (currentValue.match(/^~([0-9]*(?:\.[0-9]*)?)$/)) {
// handle ~4.1 case // handle ~4.1 case
if (toMajor > fromMajor) { if (fromVersion && toMajor > getMajor(fromVersion)) {
newValue = `~${toMajor}.0`; newValue = `~${toMajor}.0`;
} else { } else {
newValue = `~${toMajor}.${toMinor}`; newValue = `~${toMajor}.${toMinor}`;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment