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

fix(hashicorp): shortcut getNewValue only on replace

parent 6b706fb8
No related branches found
No related tags found
No related merge requests found
...@@ -35,22 +35,24 @@ function getNewValue({ ...@@ -35,22 +35,24 @@ function getNewValue({
currentVersion, currentVersion,
newVersion, newVersion,
}: NewValueConfig): string { }: NewValueConfig): string {
if (/~>\s*0\.\d+/.test(currentValue) && npm.getMajor(newVersion) === 0) { if (rangeStrategy === 'replace') {
const testFullVersion = /(~>\s*0\.)(\d+)\.\d$/; if (/~>\s*0\.\d+/.test(currentValue) && npm.getMajor(newVersion) === 0) {
let replaceValue = ''; const testFullVersion = /(~>\s*0\.)(\d+)\.\d$/;
if (testFullVersion.test(currentValue)) { let replaceValue = '';
replaceValue = `$1${npm.getMinor(newVersion)}.0`; if (testFullVersion.test(currentValue)) {
} else { replaceValue = `$1${npm.getMinor(newVersion)}.0`;
replaceValue = `$1${npm.getMinor(newVersion)}$3`; } 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)) {
return currentValue.replace(
/(~>\s*)\d+\.\d+$/,
`$1${npm.getMajor(newVersion)}.0`
);
} }
return currentValue.replace(/(~>\s*0\.)(\d+)(.*)$/, replaceValue);
}
// handle special ~> 1.2 case
if (/(~>\s*)\d+\.\d+$/.test(currentValue)) {
return currentValue.replace(
/(~>\s*)\d+\.\d+$/,
`$1${npm.getMajor(newVersion)}.0`
);
} }
return npm.getNewValue({ return npm.getNewValue({
currentValue, currentValue,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment