@@ -12,8 +12,7 @@ if (fs.realpathSync(__filename) !== __filename) {
12
12
// In case the test file imports a different AVA install,
13
13
// the presence of this variable allows it to require this one instead
14
14
const AVA_PATH = path . resolve ( __dirname , '..' ) ;
15
-
16
- const workerPath = require . resolve ( './worker/subprocess' ) ;
15
+ const WORKER_PATH = require . resolve ( './worker/subprocess' ) ;
17
16
18
17
module . exports = ( file , options , execArgv = process . execArgv ) => {
19
18
let finished = false ;
@@ -26,12 +25,12 @@ module.exports = (file, options, execArgv = process.execArgv) => {
26
25
} ;
27
26
28
27
options = {
29
- file,
30
28
baseDir : process . cwd ( ) ,
29
+ file,
31
30
...options
32
31
} ;
33
32
34
- const subprocess = childProcess . fork ( workerPath , options . workerArgv , {
33
+ const subprocess = childProcess . fork ( WORKER_PATH , options . workerArgv , {
35
34
cwd : options . projectDir ,
36
35
silent : true ,
37
36
env : { NODE_ENV : 'test' , ...process . env , ...options . environmentVariables , AVA_PATH } ,
@@ -66,15 +65,15 @@ module.exports = (file, options, execArgv = process.execArgv) => {
66
65
return ;
67
66
}
68
67
69
- if ( message . ava . type === 'ready-for-options' ) {
70
- send ( { type : ' options', options } ) ;
71
- return ;
72
- }
73
-
74
- if ( message . ava . type === 'ping' ) {
75
- send ( { type : 'pong' } ) ;
76
- } else {
77
- emitStateChange ( message . ava ) ;
68
+ switch ( message . ava . type ) {
69
+ case 'ready-for- options':
70
+ send ( { type : 'options' , options } ) ;
71
+ break ;
72
+ case 'ping' :
73
+ send ( { type : 'pong' } ) ;
74
+ break ;
75
+ default :
76
+ emitStateChange ( message . ava ) ;
78
77
}
79
78
} ) ;
80
79
@@ -99,6 +98,9 @@ module.exports = (file, options, execArgv = process.execArgv) => {
99
98
} ) ;
100
99
101
100
return {
101
+ file,
102
+ promise,
103
+
102
104
exit ( ) {
103
105
forcedExit = true ;
104
106
subprocess . kill ( ) ;
@@ -110,9 +112,6 @@ module.exports = (file, options, execArgv = process.execArgv) => {
110
112
111
113
onStateChange ( listener ) {
112
114
return emitter . on ( 'stateChange' , listener ) ;
113
- } ,
114
-
115
- file,
116
- promise
115
+ }
117
116
} ;
118
117
} ;
0 commit comments