renovate/lib/manager/nuget/update.ts
2019-07-25 08:17:19 +02:00

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;
}
}