fix: do not clone stdout/stderr passed to pugins
				
					
				
			This commit is contained in:
		
							parent
							
								
									efb40000b4
								
							
						
					
					
						commit
						63d422ed5c
					
				
							
								
								
									
										1
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								index.js
									
									
									
									
									
								
							| @ -1,4 +1,3 @@ | |||||||
| const process = require('process'); |  | ||||||
| const {template, pick} = require('lodash'); | const {template, pick} = require('lodash'); | ||||||
| const marked = require('marked'); | const marked = require('marked'); | ||||||
| const TerminalRenderer = require('marked-terminal'); | const TerminalRenderer = require('marked-terminal'); | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| const {dirname} = require('path'); | 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 resolveFrom = require('resolve-from'); | ||||||
| const getError = require('../get-error'); | const getError = require('../get-error'); | ||||||
| const {extractErrors} = require('../utils'); | const {extractErrors} = require('../utils'); | ||||||
| const PLUGINS_DEFINITIONS = require('../definitions/plugins'); | 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) { |   if (!pluginOpt) { | ||||||
|     return noop; |     return noop; | ||||||
|   } |   } | ||||||
| @ -31,7 +31,12 @@ module.exports = ({cwd, options, logger}, type, pluginOpt, pluginsPath) => { | |||||||
|     const {outputValidator} = PLUGINS_DEFINITIONS[type] || {}; |     const {outputValidator} = PLUGINS_DEFINITIONS[type] || {}; | ||||||
|     try { |     try { | ||||||
|       logger.log(`Start step "${type}" of plugin "${pluginName}"`); |       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)) { |       if (outputValidator && !outputValidator(result)) { | ||||||
|         throw getError(`E${type.toUpperCase()}OUTPUT`, {result, pluginName}); |         throw getError(`E${type.toUpperCase()}OUTPUT`, {result, pluginName}); | ||||||
|       } |       } | ||||||
|  | |||||||
| @ -160,7 +160,10 @@ test('Plugin is called with "pluginConfig" (omitting "path", adding global confi | |||||||
|   await plugin({param: 'param'}); |   await plugin({param: 'param'}); | ||||||
| 
 | 
 | ||||||
|   t.true( |   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} | ||||||
|  |     ) | ||||||
|   ); |   ); | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user