chore: squash template fields in config log serializer

This commit is contained in:
Rhys Arkins 2017-07-02 06:28:43 +02:00
parent 372b445260
commit c4dcad7de8
3 changed files with 20 additions and 0 deletions

View file

@ -5,6 +5,7 @@ module.exports = configSerializer;
function configSerializer(config) { function configSerializer(config) {
const redactedFields = ['token', 'githubAppKey']; const redactedFields = ['token', 'githubAppKey'];
const functionFields = ['api', 'logger']; const functionFields = ['api', 'logger'];
const templateFields = ['commitMessage', 'prTitle', 'prBody'];
// eslint-disable-next-line array-callback-return // eslint-disable-next-line array-callback-return
return traverse(config).map(function scrub(val) { return traverse(config).map(function scrub(val) {
if (val && redactedFields.indexOf(this.key) !== -1) { if (val && redactedFields.indexOf(this.key) !== -1) {
@ -13,5 +14,8 @@ function configSerializer(config) {
if (val && functionFields.indexOf(this.key) !== -1) { if (val && functionFields.indexOf(this.key) !== -1) {
this.update('[Function]'); this.update('[Function]');
} }
if (val && templateFields.indexOf(this.key) !== -1) {
this.update('[Template]');
}
}); });
} }

View file

@ -15,3 +15,11 @@ Object {
"nottoken": "b", "nottoken": "b",
} }
`; `;
exports[`logger/config-serializer squashes templates 1`] = `
Object {
"api": "[Function]",
"nottoken": "b",
"prBody": "[Template]",
}
`;

View file

@ -17,4 +17,12 @@ describe('logger/config-serializer', () => {
}; };
expect(configSerializer(config)).toMatchSnapshot(); expect(configSerializer(config)).toMatchSnapshot();
}); });
it('squashes templates', () => {
const config = {
api: 'a',
nottoken: 'b',
prBody: 'foo',
};
expect(configSerializer(config)).toMatchSnapshot();
});
}); });