mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
a0e2a18e7a
"docker" in config now refers to the Docker "language", which is the parent of dockerfile, docker-compose and circleci managers.
29 lines
904 B
JavaScript
29 lines
904 B
JavaScript
const { getNewFrom } = require('../dockerfile/update');
|
|
|
|
module.exports = {
|
|
updateDependency,
|
|
};
|
|
|
|
function updateDependency(fileContent, upgrade) {
|
|
try {
|
|
const newFrom = getNewFrom(upgrade);
|
|
logger.debug(`docker-compose.updateDependency(): ${newFrom}`);
|
|
const lines = fileContent.split('\n');
|
|
const lineToChange = lines[upgrade.lineNumber];
|
|
const imageLine = new RegExp(/^(\s*image:\s*'?"?)[^\s'"]+('?"?\s*)$/);
|
|
if (!lineToChange.match(imageLine)) {
|
|
logger.debug('No image line found');
|
|
return null;
|
|
}
|
|
const newLine = lineToChange.replace(imageLine, `$1${newFrom}$2`);
|
|
if (newLine === lineToChange) {
|
|
logger.debug('No changes necessary');
|
|
return fileContent;
|
|
}
|
|
lines[upgrade.lineNumber] = newLine;
|
|
return lines.join('\n');
|
|
} catch (err) {
|
|
logger.info({ err }, 'Error setting new Dockerfile value');
|
|
return null;
|
|
}
|
|
}
|