mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-15 00:56:26 +00:00
d8cb261ecb
Renames currentVersion to currentValue, newVersion to newValue, newVersionMajor to newMajor, and newVersionMinor to newMinor.
26 lines
819 B
JavaScript
26 lines
819 B
JavaScript
module.exports = {
|
|
updateDependency,
|
|
};
|
|
|
|
function updateDependency(currentFileContent, upgrade) {
|
|
try {
|
|
logger.debug(`buildkite.updateDependency: ${upgrade.newValue}`);
|
|
const lines = currentFileContent.split('\n');
|
|
const lineToChange = lines[upgrade.lineNumber];
|
|
const depLine = new RegExp(/^(\s+[^#]+#)[^:]+(:.*)$/);
|
|
if (!lineToChange.match(depLine)) {
|
|
logger.debug('No image line found');
|
|
return null;
|
|
}
|
|
const newLine = lineToChange.replace(depLine, `$1${upgrade.newValue}$2`);
|
|
if (newLine === lineToChange) {
|
|
logger.debug('No changes necessary');
|
|
return currentFileContent;
|
|
}
|
|
lines[upgrade.lineNumber] = newLine;
|
|
return lines.join('\n');
|
|
} catch (err) {
|
|
logger.info({ err }, 'Error setting new buildkite version');
|
|
return null;
|
|
}
|
|
}
|