diff --git a/lib/versioning/semver-composer/index.js b/lib/versioning/semver-composer/index.js index c1d5b6564c7da7d627088ed79c02c84cb88d47aa..064caee4202744dbd0d6263e56f405fa2c5298e5 100644 --- a/lib/versioning/semver-composer/index.js +++ b/lib/versioning/semver-composer/index.js @@ -55,7 +55,6 @@ const minSatisfyingVersion = (versions, range) => semver.minSatisfyingVersion(versions.map(composer2npm), composer2npm(range)); function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) { - const fromMajor = getMajor(fromVersion); const toMajor = getMajor(toVersion); const toMinor = getMinor(toVersion); let newValue; @@ -84,7 +83,7 @@ function getNewValue(currentValue, rangeStrategy, fromVersion, toVersion) { newValue = `~${toMajor}`; } else if (currentValue.match(/^~([0-9]*(?:\.[0-9]*)?)$/)) { // handle ~4.1 case - if (toMajor > fromMajor) { + if (fromVersion && toMajor > getMajor(fromVersion)) { newValue = `~${toMajor}.0`; } else { newValue = `~${toMajor}.${toMinor}`;