renovate/lib/manager/docker/update.js
2018-03-30 06:05:00 +02:00

22 lines
684 B
JavaScript

module.exports = {
updateDependency,
};
function updateDependency(fileContent, upgrade) {
try {
logger.debug(`docker.updateDependency(): ${upgrade.newFrom}`);
const oldLine = new RegExp(
`(^|\\n)${upgrade.fromPrefix}(\\s+)${
upgrade.dockerRegistry ? upgrade.dockerRegistry + '/' : ''
}${upgrade.depName}[^\\s]*(\\s?)${upgrade.fromSuffix}\\n`
);
const newLine = `$1${upgrade.fromPrefix}$2${upgrade.newFrom}$3${
upgrade.fromSuffix
}\n`;
const newFileContent = fileContent.replace(oldLine, newLine);
return newFileContent;
} catch (err) {
logger.info({ err }, 'Error setting new Dockerfile value');
return null;
}
}