@@ -16,11 +16,11 @@ module.exports = (function () {
16
16
var harness ;
17
17
18
18
function getHarness ( opts ) {
19
- if ( ! opts ) { opts = { } ; }
20
- opts . autoclose = ! canEmitExit ;
21
19
// this override is here since tests fail via nyc if createHarness is moved upwards
22
- // eslint-disable-next-line no-use-before-define
23
- if ( ! harness ) { harness = createExitHarness ( opts , wait ) ; }
20
+ if ( ! harness ) {
21
+ // eslint-disable-next-line no-use-before-define
22
+ harness = createExitHarness ( opts || { } , wait ) ;
23
+ }
24
24
return harness ;
25
25
}
26
26
@@ -120,20 +120,24 @@ function createHarness(conf_) {
120
120
return test ;
121
121
}
122
122
123
- function createExitHarness ( conf , wait ) {
124
- var config = conf || { } ;
123
+ function createExitHarness ( config , wait ) {
124
+ var noOnly = config . noOnly ;
125
+ var objectMode = config . objectMode ;
126
+ var cStream = config . stream ;
127
+ var exit = config . exit ;
128
+
125
129
var harness = createHarness ( {
126
- autoclose : defined ( config . autoclose , false ) ,
127
- noOnly : defined ( conf . noOnly , defined ( process . env . NODE_TAPE_NO_ONLY_TEST , false ) )
130
+ autoclose : ! canEmitExit ,
131
+ noOnly : defined ( noOnly , defined ( process . env . NODE_TAPE_NO_ONLY_TEST , false ) )
128
132
} ) ;
129
133
var running = false ;
130
134
var ended = false ;
131
135
132
136
function run ( ) {
133
137
if ( running ) { return ; }
134
138
running = true ;
135
- var stream = harness . createStream ( { objectMode : config . objectMode } ) ;
136
- var es = stream . pipe ( config . stream || createDefaultStream ( ) ) ;
139
+ var stream = harness . createStream ( { objectMode : objectMode } ) ;
140
+ var es = stream . pipe ( cStream || createDefaultStream ( ) ) ;
137
141
if ( canEmitExit && es ) { // in node v0.4, `es` is `undefined`
138
142
// TODO: use `err` arg?
139
143
// eslint-disable-next-line no-unused-vars
@@ -148,7 +152,7 @@ function createExitHarness(conf, wait) {
148
152
run ( ) ;
149
153
}
150
154
151
- if ( config . exit === false ) { return harness ; }
155
+ if ( exit === false ) { return harness ; }
152
156
if ( ! canEmitExit || ! canExit ) { return harness ; }
153
157
154
158
process . on ( 'exit' , function ( code ) {
0 commit comments