mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
fix(validation): massage config (#28458)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
This commit is contained in:
parent
7c598d6d33
commit
0a438657e8
2 changed files with 29 additions and 2 deletions
20
lib/workers/global/config/parse/util.spec.ts
Normal file
20
lib/workers/global/config/parse/util.spec.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { logger } from '../../../../logger';
|
||||
import { migrateAndValidateConfig } from './util';
|
||||
|
||||
describe('workers/global/config/parse/util', () => {
|
||||
it('massages config', async () => {
|
||||
const config = {
|
||||
packageRules: [
|
||||
{
|
||||
description: 'haha',
|
||||
matchPackageNames: ['name'],
|
||||
enabled: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const migratedConfig = await migrateAndValidateConfig(config, 'global');
|
||||
expect(migratedConfig?.packageRules?.[0].description).toBeArray();
|
||||
expect(logger.warn).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
|
@ -1,3 +1,5 @@
|
|||
import { dequal } from 'dequal';
|
||||
import { massageConfig } from '../../../../config/massage';
|
||||
import { migrateConfig } from '../../../../config/migration';
|
||||
import type { RenovateConfig } from '../../../../config/types';
|
||||
import { validateConfig } from '../../../../config/validation';
|
||||
|
@ -14,8 +16,13 @@ export async function migrateAndValidateConfig(
|
|||
`${configType} needs migrating`,
|
||||
);
|
||||
}
|
||||
const massagedConfig = massageConfig(migratedConfig);
|
||||
// log only if it's changed
|
||||
if (!dequal(migratedConfig, massagedConfig)) {
|
||||
logger.trace({ config: massagedConfig }, 'Post-massage config');
|
||||
}
|
||||
|
||||
const { warnings, errors } = await validateConfig('global', migratedConfig);
|
||||
const { warnings, errors } = await validateConfig('global', massagedConfig);
|
||||
|
||||
if (warnings.length) {
|
||||
logger.warn(
|
||||
|
@ -27,5 +34,5 @@ export async function migrateAndValidateConfig(
|
|||
logger.warn({ errors }, `Config validation errors found in ${configType}`);
|
||||
}
|
||||
|
||||
return migratedConfig;
|
||||
return massagedConfig;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue