mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 15:36:25 +00:00
26 lines
683 B
JavaScript
26 lines
683 B
JavaScript
const { logger } = require('../../../logger');
|
|
const { mergeChildConfig } = require('../../../config');
|
|
|
|
function flattenPackageRules(packageRules) {
|
|
const res = [];
|
|
if (!(packageRules && packageRules.length)) {
|
|
return res;
|
|
}
|
|
for (const rule of packageRules) {
|
|
if (rule.packageRules && rule.packageRules.length) {
|
|
logger.info('Flattening nested packageRules');
|
|
for (const subrule of rule.packageRules) {
|
|
const combinedRule = mergeChildConfig(rule, subrule);
|
|
delete combinedRule.packageRules;
|
|
res.push(combinedRule);
|
|
}
|
|
} else {
|
|
res.push(rule);
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
|
|
module.exports = {
|
|
flattenPackageRules,
|
|
};
|