Skip to content
Snippets Groups Projects
Unverified Commit df2f451e authored by Sebastian Poxhofer's avatar Sebastian Poxhofer Committed by GitHub
Browse files

fix(terraform): handle greater than with full version (#9632)

parent 8b8d7767
No related branches found
No related tags found
No related merge requests found
......@@ -67,6 +67,30 @@ describe('semver.getNewValue()', () => {
newVersion: '2.0.7',
})
).toEqual('~> 2.0.0');
expect(
semver.getNewValue({
currentValue: '~> 0.14.0',
rangeStrategy: 'replace',
currentVersion: '0.14.1',
newVersion: '0.15.0',
})
).toEqual('~> 0.15.0');
expect(
semver.getNewValue({
currentValue: '~> 0.14.0',
rangeStrategy: 'replace',
currentVersion: '0.14.1',
newVersion: '0.15.1',
})
).toEqual('~> 0.15.0');
expect(
semver.getNewValue({
currentValue: '~> 0.14.6',
rangeStrategy: 'replace',
currentVersion: '0.14.6',
newVersion: '0.15.0',
})
).toEqual('~> 0.15.0');
});
it('handles comma dividers', () => {
expect(
......
......@@ -36,10 +36,14 @@ function getNewValue({
newVersion,
}: NewValueConfig): string {
if (/~>\s*0\.\d+/.test(currentValue) && npm.getMajor(newVersion) === 0) {
return currentValue.replace(
/(~>\s*0\.).*$/,
`$1${npm.getMinor(newVersion)}`
);
const testFullVersion = /(~>\s*0\.)(\d+)\.\d$/;
let replaceValue = '';
if (testFullVersion.test(currentValue)) {
replaceValue = `$1${npm.getMinor(newVersion)}.0`;
} else {
replaceValue = `$1${npm.getMinor(newVersion)}$3`;
}
return currentValue.replace(/(~>\s*0\.)(\d+)(.*)$/, replaceValue);
}
// handle special ~> 1.2 case
if (/(~>\s*)\d+\.\d+$/.test(currentValue)) {
......
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