@@ -12,7 +12,7 @@ const basicConfigPath = path.resolve(
12
12
'../fixtures/cli/webpack.config.js'
13
13
) ;
14
14
15
- function runWebackDevServer ( testArgs , configPath ) {
15
+ function testBin ( testArgs , configPath ) {
16
16
const cwd = process . cwd ( ) ;
17
17
const env = process . env . NODE_ENV ;
18
18
let stdout = '' ;
@@ -36,14 +36,21 @@ function runWebackDevServer(testArgs, configPath) {
36
36
child . on ( 'error' , ( error ) => reject ( error ) ) ;
37
37
38
38
child . stdout . on ( 'data' , ( data ) => {
39
- stdout += data . toString ( ) ;
39
+ const str = data . toString ( ) ;
40
+
41
+ stdout += str ;
42
+
43
+ // if webpack.config.js is a promise function, it won't be able to call `close`
44
+ if ( str . includes ( 'Compiled successfully.' ) ) {
45
+ child . kill ( 'SIGINT' ) ;
46
+ }
40
47
} ) ;
41
48
42
49
child . stderr . on ( 'data' , ( data ) => {
43
50
stderr += data . toString ( ) ;
44
51
} ) ;
45
52
46
- child . on ( 'close ' , ( code ) => {
53
+ child . on ( 'exit ' , ( code ) => {
47
54
if ( code !== 0 ) {
48
55
return reject ( stderr ) ;
49
56
}
@@ -52,4 +59,4 @@ function runWebackDevServer(testArgs, configPath) {
52
59
} ) ;
53
60
}
54
61
55
- module . exports = runWebackDevServer ;
62
+ module . exports = testBin ;
0 commit comments