1+ "use strict" ;
2+
13const output = require ( '../src/output' ) ;
24const webpack = require ( 'webpack' ) ;
35const FriendlyErrorsWebpackPlugin = require ( '../src/friendly-errors-plugin' ) ;
46const MemoryFileSystem = require ( 'memory-fs' ) ;
57
6- const webpackPromise = function ( config , ... globalPlugins ) {
8+ const webpackPromise = function ( config , globalPlugins ) {
79 const compiler = webpack ( config ) ;
810 compiler . outputFileSystem = new MemoryFileSystem ( ) ;
9- globalPlugins . forEach ( p => compiler . apply ( p ) ) ;
11+ if ( Array . isArray ( globalPlugins ) ) {
12+ globalPlugins . forEach ( p => compiler . apply ( p ) ) ;
13+ }
1014
1115 return new Promise ( ( resolve , reject ) => {
1216 compiler . run ( err => {
@@ -18,10 +22,10 @@ const webpackPromise = function(config, ...globalPlugins) {
1822 } ) ;
1923} ;
2024
21- async function executeAndGetLogs ( fixture , ... globalPlugins ) {
25+ async function executeAndGetLogs ( fixture , globalPlugins ) {
2226 try {
2327 output . capture ( ) ;
24- await webpackPromise ( require ( fixture ) , ... globalPlugins ) ;
28+ await webpackPromise ( require ( fixture ) , globalPlugins ) ;
2529 return output . capturedMessages ;
2630 } finally {
2731 output . endCapture ( )
@@ -96,15 +100,17 @@ it('integration : babel syntax error', async () => {
96100it ( 'integration : webpack multi compiler : success' , async ( ) => {
97101
98102 // We apply the plugin directly to the compiler when targeting multi-compiler
99- const logs = await executeAndGetLogs ( './fixtures/multi-compiler-success/webpack.config' , new FriendlyErrorsWebpackPlugin ( ) ) ;
103+ let globalPlugins = [ new FriendlyErrorsWebpackPlugin ( ) ] ;
104+ const logs = await executeAndGetLogs ( './fixtures/multi-compiler-success/webpack.config' , globalPlugins ) ;
100105
101106 expect ( logs . join ( '\n' ) ) . toMatch ( / D O N E C o m p i l e d s u c c e s s f u l l y i n ( .\d * ) m s / )
102107} ) ;
103108
104109it ( 'integration : webpack multi compiler : module-errors' , async ( ) => {
105110
106111 // We apply the plugin directly to the compiler when targeting multi-compiler
107- const logs = await executeAndGetLogs ( './fixtures/multi-compiler-module-errors/webpack.config' , new FriendlyErrorsWebpackPlugin ( ) ) ;
112+ let globalPlugins = [ new FriendlyErrorsWebpackPlugin ( ) ] ;
113+ const logs = await executeAndGetLogs ( './fixtures/multi-compiler-module-errors/webpack.config' , globalPlugins ) ;
108114
109115 expect ( logs ) . toEqual ( [
110116 ' ERROR Failed to compile with 2 errors' ,
0 commit comments