Skip to content

Commit

Permalink
fix: do not clone stdout/stderr passed to pugins
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Aug 5, 2018
1 parent efb4000 commit 63d422e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 0 additions & 1 deletion index.js
@@ -1,4 +1,3 @@
const process = require('process');
const {template, pick} = require('lodash');
const marked = require('marked');
const TerminalRenderer = require('marked-terminal');
Expand Down
11 changes: 8 additions & 3 deletions lib/plugins/normalize.js
@@ -1,11 +1,11 @@
const {dirname} = require('path');
const {isString, isPlainObject, isFunction, noop, cloneDeep} = require('lodash');
const {isString, isPlainObject, isFunction, noop, cloneDeep, omit} = require('lodash');
const resolveFrom = require('resolve-from');
const getError = require('../get-error');
const {extractErrors} = require('../utils');
const PLUGINS_DEFINITIONS = require('../definitions/plugins');

module.exports = ({cwd, options, logger}, type, pluginOpt, pluginsPath) => {
module.exports = ({cwd, stdout, stderr, options, logger}, type, pluginOpt, pluginsPath) => {
if (!pluginOpt) {
return noop;
}
Expand All @@ -31,7 +31,12 @@ module.exports = ({cwd, options, logger}, type, pluginOpt, pluginsPath) => {
const {outputValidator} = PLUGINS_DEFINITIONS[type] || {};
try {
logger.log(`Start step "${type}" of plugin "${pluginName}"`);
const result = await func({...cloneDeep(input), logger: logger.scope(logger.scopeName, pluginName)});
const result = await func({
...cloneDeep(omit(input, ['stdout', 'stderr', 'logger'])),
stdout,
stderr,
logger: logger.scope(logger.scopeName, pluginName),
});
if (outputValidator && !outputValidator(result)) {
throw getError(`E${type.toUpperCase()}OUTPUT`, {result, pluginName});
}
Expand Down
5 changes: 4 additions & 1 deletion test/plugins/normalize.test.js
Expand Up @@ -160,7 +160,10 @@ test('Plugin is called with "pluginConfig" (omitting "path", adding global confi
await plugin({param: 'param'});

t.true(
pluginFunction.calledWith({conf: 'confValue', global: 'globalValue'}, {param: 'param', logger: t.context.logger})
pluginFunction.calledWithMatch(
{conf: 'confValue', global: 'globalValue'},
{param: 'param', logger: t.context.logger}
)
);
});

Expand Down

0 comments on commit 63d422e

Please sign in to comment.