mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
22 lines
613 B
JavaScript
22 lines
613 B
JavaScript
const { dependencyPattern } = require('./extract');
|
|
|
|
module.exports = {
|
|
updateDependency,
|
|
};
|
|
|
|
function updateDependency(fileContent, upgrade) {
|
|
try {
|
|
logger.debug(`pip_requirements.updateDependency(): ${upgrade.newValue}`);
|
|
const lines = fileContent.split('\n');
|
|
const oldValue = lines[upgrade.lineNumber];
|
|
const newValue = oldValue.replace(
|
|
new RegExp(dependencyPattern),
|
|
`$1$2${upgrade.newValue}`
|
|
);
|
|
lines[upgrade.lineNumber] = newValue;
|
|
return lines.join('\n');
|
|
} catch (err) {
|
|
logger.info({ err }, 'Error setting new package version');
|
|
return null;
|
|
}
|
|
}
|