mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 14:36:25 +00:00
fix: try/catch dockerfile replace (#1022)
This commit is contained in:
parent
826753e329
commit
a65a149b8d
2 changed files with 26 additions and 7 deletions
|
@ -9,6 +9,7 @@ function setNewValue(
|
|||
newVersion,
|
||||
logger
|
||||
) {
|
||||
try {
|
||||
logger.debug(`setNewValue: ${depName} = ${newVersion}`);
|
||||
const regexReplace = new RegExp(`(^|\n)FROM ${currentVersion}\n`);
|
||||
const newFileContent = currentFileContent.replace(
|
||||
|
@ -16,4 +17,8 @@ function setNewValue(
|
|||
`$1FROM ${newVersion}\n`
|
||||
);
|
||||
return newFileContent;
|
||||
} catch (err) {
|
||||
logger.info({ err }, 'Error setting new Dockerfile value');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,5 +18,19 @@ describe('workers/branch/dockerfile', () => {
|
|||
);
|
||||
expect(res).toMatchSnapshot();
|
||||
});
|
||||
it('returns null on error', () => {
|
||||
const currentFileContent = null;
|
||||
const depName = 'node';
|
||||
const currentVersion = 'node:8';
|
||||
const newVersion = 'node:8@sha256:abcdefghijklmnop';
|
||||
const res = dockerfile.setNewValue(
|
||||
currentFileContent,
|
||||
depName,
|
||||
currentVersion,
|
||||
newVersion,
|
||||
logger
|
||||
);
|
||||
expect(res).toBe(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue