mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-15 09:06:25 +00:00
24 lines
767 B
TypeScript
24 lines
767 B
TypeScript
import { logger } from '../../logger';
|
|
import { Upgrade } from '../common';
|
|
|
|
export function updateDependency(
|
|
fileContent: string,
|
|
upgrade: Upgrade
|
|
): string {
|
|
try {
|
|
logger.debug(`nuget.updateDependency(): ${upgrade.newFrom}`);
|
|
const lines = fileContent.split('\n');
|
|
const lineToChange = lines[upgrade.managerData.lineNumber];
|
|
const regex = /(Version\s*=\s*")([^"]+)/;
|
|
const newLine = lineToChange.replace(regex, `$1${upgrade.newVersion}`);
|
|
if (newLine === lineToChange) {
|
|
logger.debug('No changes necessary');
|
|
return fileContent;
|
|
}
|
|
lines[upgrade.managerData.lineNumber] = newLine;
|
|
return lines.join('\n');
|
|
} catch (err) {
|
|
logger.info({ err }, 'Error setting new Dockerfile value');
|
|
return null;
|
|
}
|
|
}
|