0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-02-23 16:38:52 +00:00

fix: support constraints.node override ()

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
Rhys Arkins 2020-10-27 09:01:48 +01:00 committed by GitHub
parent 989a21cded
commit 3bffe6fae7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 1 deletions

View file

@ -244,6 +244,18 @@ Constraints are also used to manually restrict which _datasource_ versions are p
}
```
If you need to _override_ constraints that Renovate detects from the repository, wrap it in the `force` object like so:
```json
{
"force": {
"constraints": {
"node": "< 15.0.0"
}
}
}
```
Note: make sure not to mix this up with the term `compatibility`, which Renovate uses in the context of version releases, e.g. if a Docker image is `node:12.16.0-alpine` then the `-alpine` suffix represents `compatibility`.
## dependencyDashboard

View file

@ -18,3 +18,10 @@ Object {
],
}
`;
exports[`config/index mergeChildConfig(parentConfig, childConfig) merges constraints 1`] = `
Object {
"node": "<15",
"npm": "^6.0.0",
}
`;

View file

@ -153,6 +153,24 @@ describe('config/index', () => {
4,
]);
});
it('merges constraints', async () => {
const parentConfig = { ...defaultConfig };
Object.assign(parentConfig, {
constraints: {
node: '>=12',
npm: '^6.0.0',
},
});
const childConfig = {
constraints: {
node: '<15',
},
};
const configParser = await import('./index');
const config = configParser.mergeChildConfig(parentConfig, childConfig);
expect(config.constraints).toMatchSnapshot();
expect(config.constraints.node).toEqual('<15');
});
it('handles null parent packageRules', async () => {
const parentConfig = { ...defaultConfig };
Object.assign(parentConfig, {

View file

@ -21,7 +21,12 @@ export function mergeChildConfig<T, TChild>(
parentConfig[option.name]
) {
logger.trace(`mergeable option: ${option.name}`);
if (option.type === 'array') {
if (option.name === 'constraints') {
config[option.name] = Object.assign(
parentConfig[option.name],
childConfig[option.name]
);
} else if (option.type === 'array') {
config[option.name] = (parentConfig[option.name] as unknown[]).concat(
config[option.name]
);