2017-06-22 07:03:36 +00:00
|
|
|
const traverse = require('traverse');
|
|
|
|
|
|
|
|
module.exports = configSerializer;
|
|
|
|
|
|
|
|
function configSerializer(config) {
|
2017-08-29 07:25:44 +00:00
|
|
|
const redactedFields = [
|
|
|
|
'token',
|
|
|
|
'githubAppKey',
|
|
|
|
'npmToken',
|
|
|
|
'npmrc',
|
|
|
|
'yarnrc',
|
2017-09-01 04:45:51 +00:00
|
|
|
'privateKey',
|
2017-08-29 07:25:44 +00:00
|
|
|
];
|
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('***********');
|
|
|
|
}
|
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
|
|
|
});
|
|
|
|
}
|