2019-11-29 12:52:46 +00:00
|
|
|
import traverse from 'traverse';
|
2021-03-02 20:44:55 +00:00
|
|
|
import type { RenovateConfig } from '../config/types';
|
2017-06-22 07:03:36 +00:00
|
|
|
|
2019-11-29 12:52:46 +00:00
|
|
|
export default function configSerializer(
|
|
|
|
config: RenovateConfig
|
|
|
|
): RenovateConfig {
|
2018-04-17 08:34:30 +00:00
|
|
|
const templateFields = ['prBody'];
|
2018-03-08 06:22:06 +00:00
|
|
|
const contentFields = [
|
|
|
|
'content',
|
|
|
|
'contents',
|
|
|
|
'packageLockParsed',
|
|
|
|
'yarnLockParsed',
|
|
|
|
];
|
2018-05-03 12:17:45 +00:00
|
|
|
const arrayFields = ['packageFiles', 'upgrades'];
|
2019-11-29 12:52:46 +00:00
|
|
|
|
2019-07-17 08:14:56 +00:00
|
|
|
return traverse(config).map(
|
|
|
|
// eslint-disable-next-line array-callback-return
|
2019-11-29 12:52:46 +00:00
|
|
|
function scrub(val: string) {
|
2019-07-17 08:14:56 +00:00
|
|
|
if (val && templateFields.includes(this.key)) {
|
|
|
|
this.update('[Template]');
|
|
|
|
}
|
|
|
|
if (val && contentFields.includes(this.key)) {
|
|
|
|
this.update('[content]');
|
|
|
|
}
|
|
|
|
// istanbul ignore if
|
|
|
|
if (val && arrayFields.includes(this.key)) {
|
|
|
|
this.update('[Array]');
|
|
|
|
}
|
2017-06-22 07:03:36 +00:00
|
|
|
}
|
2019-07-17 08:14:56 +00:00
|
|
|
);
|
2017-06-22 07:03:36 +00:00
|
|
|
}
|