2017-06-22 07:03:36 +00:00
|
|
|
const traverse = require('traverse');
|
|
|
|
|
|
|
|
module.exports = configSerializer;
|
|
|
|
|
|
|
|
function configSerializer(config) {
|
|
|
|
const redactedFields = ['token', 'githubAppKey'];
|
|
|
|
const functionFields = ['api', 'logger'];
|
2017-07-02 04:28:43 +00:00
|
|
|
const templateFields = ['commitMessage', 'prTitle', 'prBody'];
|
2017-06-22 07:03:36 +00:00
|
|
|
// eslint-disable-next-line array-callback-return
|
|
|
|
return traverse(config).map(function scrub(val) {
|
|
|
|
if (val && redactedFields.indexOf(this.key) !== -1) {
|
|
|
|
this.update('***********');
|
|
|
|
}
|
|
|
|
if (val && functionFields.indexOf(this.key) !== -1) {
|
|
|
|
this.update('[Function]');
|
|
|
|
}
|
2017-07-02 04:28:43 +00:00
|
|
|
if (val && templateFields.indexOf(this.key) !== -1) {
|
|
|
|
this.update('[Template]');
|
|
|
|
}
|
2017-08-26 14:10:18 +00:00
|
|
|
if (this.key === 'content' || this.key === 'contents') {
|
2017-08-08 04:25:44 +00:00
|
|
|
this.update('[content]');
|
|
|
|
}
|
2017-06-22 07:03:36 +00:00
|
|
|
});
|
|
|
|
}
|