mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
fix(terraform): check line validity (#12102)
This commit is contained in:
parent
f74404b3c2
commit
da1b7d54a3
1 changed files with 15 additions and 14 deletions
|
@ -36,24 +36,25 @@ export function extractTerraformProvider(
|
||||||
}
|
}
|
||||||
|
|
||||||
const line = lines[lineNumber];
|
const line = lines[lineNumber];
|
||||||
// `{` will be counted wit +1 and `}` with -1. Therefore if we reach braceCounter == 0. We have found the end of the terraform block
|
if (line) {
|
||||||
const openBrackets = (line.match(/\{/g) || []).length;
|
// `{` will be counted wit +1 and `}` with -1. Therefore if we reach braceCounter == 0. We have found the end of the terraform block
|
||||||
const closedBrackets = (line.match(/\}/g) || []).length;
|
const openBrackets = (line.match(/\{/g) || []).length;
|
||||||
braceCounter = braceCounter + openBrackets - closedBrackets;
|
const closedBrackets = (line.match(/\}/g) || []).length;
|
||||||
|
braceCounter = braceCounter + openBrackets - closedBrackets;
|
||||||
|
|
||||||
// only update fields inside the root block
|
// only update fields inside the root block
|
||||||
if (braceCounter === 1) {
|
if (braceCounter === 1) {
|
||||||
const kvMatch = keyValueExtractionRegex.exec(line);
|
const kvMatch = keyValueExtractionRegex.exec(line);
|
||||||
if (kvMatch) {
|
if (kvMatch) {
|
||||||
if (kvMatch.groups.key === 'version') {
|
if (kvMatch.groups.key === 'version') {
|
||||||
dep.currentValue = kvMatch.groups.value;
|
dep.currentValue = kvMatch.groups.value;
|
||||||
} else if (kvMatch.groups.key === 'source') {
|
} else if (kvMatch.groups.key === 'source') {
|
||||||
dep.managerData.source = kvMatch.groups.value;
|
dep.managerData.source = kvMatch.groups.value;
|
||||||
dep.managerData.sourceLine = lineNumber;
|
dep.managerData.sourceLine = lineNumber;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lineNumber += 1;
|
lineNumber += 1;
|
||||||
} while (braceCounter !== 0);
|
} while (braceCounter !== 0);
|
||||||
deps.push(dep);
|
deps.push(dep);
|
||||||
|
|
Loading…
Reference in a new issue