- Allow to run semantic-release (via API) from anywhere passing the current working directory. - Allows to simplify the tests and to run them in parallel in both the core and plugins.
14 lines
511 B
JavaScript
14 lines
511 B
JavaScript
const {escapeRegExp} = require('lodash');
|
|
const {SECRET_REPLACEMENT} = require('./definitions/constants');
|
|
|
|
module.exports = env => {
|
|
const toReplace = Object.keys(env).filter(
|
|
envVar => /token|password|credential|secret|private/i.test(envVar) && env[envVar].trim()
|
|
);
|
|
|
|
const regexp = new RegExp(toReplace.map(envVar => escapeRegExp(env[envVar])).join('|'), 'g');
|
|
return output => {
|
|
return output && toReplace.length > 0 ? output.toString().replace(regexp, SECRET_REPLACEMENT) : output;
|
|
};
|
|
};
|