@@ -60,32 +60,47 @@ function createWebpackConfig(testAppDir, outputDirName = '', command, argv = {})
60
60
}
61
61
62
62
function runWebpack ( webpackConfig , callback , allowCompilationError = false ) {
63
- validator ( webpackConfig ) ;
64
- const compiler = webpack ( configGenerator ( webpackConfig ) ) ;
65
- compiler . run ( ( err , stats ) => {
66
- if ( err ) {
67
- console . error ( err . stack || err ) ;
68
- if ( err . details ) {
69
- console . error ( err . details ) ;
70
- }
63
+ const stdoutWrite = process . stdout . write ;
71
64
72
- throw new Error ( 'Error running webpack!' ) ;
73
- }
65
+ try {
66
+ // Mute stdout
67
+ process . stdout . write = ( ) => { } ;
74
68
75
- const info = stats . toJson ( ) ;
69
+ validator ( webpackConfig ) ;
76
70
77
- if ( stats . hasErrors ( ) && ! allowCompilationError ) {
78
- console . error ( info . errors ) ;
71
+ const compiler = webpack ( configGenerator ( webpackConfig ) ) ;
72
+ compiler . run ( ( err , stats ) => {
79
73
80
- throw new Error ( 'Compilation error running webpack!' ) ;
81
- }
74
+ if ( err ) {
75
+ console . error ( err . stack || err ) ;
76
+ if ( err . details ) {
77
+ console . error ( err . details ) ;
78
+ }
82
79
83
- if ( stats . hasWarnings ( ) ) {
84
- console . warn ( info . warnings ) ;
85
- }
80
+ throw new Error ( 'Error running webpack!' ) ;
81
+ }
86
82
87
- callback ( assertUtil ( webpackConfig ) , stats ) ;
88
- } ) ;
83
+ const info = stats . toJson ( ) ;
84
+
85
+ if ( stats . hasErrors ( ) && ! allowCompilationError ) {
86
+ console . error ( info . errors ) ;
87
+
88
+ throw new Error ( 'Compilation error running webpack!' ) ;
89
+ }
90
+
91
+ if ( stats . hasWarnings ( ) ) {
92
+ console . warn ( info . warnings ) ;
93
+ }
94
+
95
+ // Restore stdout and then call the callback
96
+ process . stdout . write = stdoutWrite ;
97
+ callback ( assertUtil ( webpackConfig ) , stats ) ;
98
+ } ) ;
99
+ } catch ( e ) {
100
+ // Restore stdout and then re-throw the exception
101
+ process . stdout . write = stdoutWrite ;
102
+ throw e ;
103
+ }
89
104
}
90
105
91
106
function emptyTmpDir ( ) {
@@ -158,6 +173,7 @@ function requestTestPage(webRootDir, scriptSrcs, callback) {
158
173
startHttpServer ( '8090' , webRootDir ) ;
159
174
160
175
const browser = new Browser ( ) ;
176
+ browser . silent = true ;
161
177
browser . on ( 'error' , function ( error ) {
162
178
throw new Error ( `Error when running the browser: ${ error } ` ) ;
163
179
} ) ;
0 commit comments