@@ -20,20 +20,6 @@ const getProcessForPort = require('./getProcessForPort');
20
20
const typescriptFormatter = require ( './typescriptFormatter' ) ;
21
21
22
22
const isInteractive = process . stdout . isTTY ;
23
- let handleCompile ;
24
-
25
- // You can safely remove this after ejecting.
26
- // We only use this block for testing of Create React App itself:
27
- const isSmokeTest = process . argv . some ( arg => arg . indexOf ( '--smoke-test' ) > - 1 ) ;
28
- if ( isSmokeTest ) {
29
- handleCompile = ( err , stats ) => {
30
- if ( err || stats . hasErrors ( ) || stats . hasWarnings ( ) ) {
31
- process . exit ( 1 ) ;
32
- } else {
33
- process . exit ( 0 ) ;
34
- }
35
- } ;
36
- }
37
23
38
24
function prepareUrls ( protocol , host , port ) {
39
25
const formatUrl = hostname =>
@@ -119,7 +105,7 @@ function createCompiler(webpack, config, appName, urls, useYarn, useTypeScript,
119
105
// It lets us listen to some events and provide our own custom messages.
120
106
let compiler ;
121
107
try {
122
- compiler = webpack ( config , handleCompile ) ;
108
+ compiler = webpack ( config ) ;
123
109
} catch ( err ) {
124
110
console . log ( chalk . red ( 'Failed to compile.' ) ) ;
125
111
console . log ( ) ;
@@ -128,6 +114,20 @@ function createCompiler(webpack, config, appName, urls, useYarn, useTypeScript,
128
114
process . exit ( 1 ) ;
129
115
}
130
116
117
+ // You can safely remove this after ejecting.
118
+ // We only use this block for testing of Create React App itself:
119
+ const isSmokeTest = process . argv . some ( arg => arg . indexOf ( '--smoke-test' ) > - 1 ) ;
120
+ if ( isSmokeTest ) {
121
+ compiler . hooks . failed . tap ( 'smokeTest' , ( ) => process . exit ( 1 ) ) ;
122
+ compiler . hooks . done . tap ( 'smokeTest' , stats => {
123
+ if ( stats . hasErrors ( ) || stats . hasWarnings ( ) ) {
124
+ process . exit ( 1 ) ;
125
+ } else {
126
+ process . exit ( 0 ) ;
127
+ }
128
+ } ) ;
129
+ }
130
+
131
131
// "invalid" event fires when you have changed a file, and Webpack is
132
132
// recompiling a bundle. WebpackDevServer takes care to pause serving the
133
133
// bundle, so if you refresh, it'll wait instead of serving the old one.
0 commit comments