@@ -47,7 +47,7 @@ describe('cli', () => {
4747 '--no-ignore' , './test/fixtures'
4848 ] )
4949
50- expect ( exitCode ) . toBe ( 0 )
50+ expect ( exitCode ) . toBe ( 1 )
5151 expect ( stderr ) . toBe ( '' )
5252 expect ( stdout ) . toEqual ( expect . stringContaining ( `first${ sep } index.js` ) )
5353 expect ( stdout ) . toEqual ( expect . not . stringContaining ( '2x' ) )
@@ -62,7 +62,7 @@ describe('cli', () => {
6262 '--no-ignore' , './test/fixtures'
6363 ] )
6464
65- expect ( exitCode ) . toBe ( 0 )
65+ expect ( exitCode ) . toBe ( 1 )
6666 expect ( stderr ) . toBe ( '' )
6767 expect ( stdout ) . toEqual ( expect . stringContaining ( '2x' ) )
6868 expect ( stdout ) . toEqual ( expect . stringContaining ( 'index.js' ) )
@@ -78,7 +78,7 @@ describe('cli', () => {
7878 '--no-ignore' , './test/fixtures'
7979 ] )
8080
81- expect ( exitCode ) . toBe ( 0 )
81+ expect ( exitCode ) . toBe ( 1 )
8282 expect ( stderr ) . toBe ( '' )
8383 expect ( stdout ) . toEqual ( expect . stringContaining ( '2x' ) )
8484 expect ( stdout ) . toEqual ( expect . stringContaining ( 'index.js' ) )
@@ -94,7 +94,7 @@ describe('cli', () => {
9494 '--no-ignore' , './test/fixtures'
9595 ] )
9696
97- expect ( exitCode ) . toBe ( 0 )
97+ expect ( exitCode ) . toBe ( 1 )
9898 expect ( stderr ) . toBe ( '' )
9999 expect ( stdout ) . toEqual ( expect . stringContaining ( '2x' ) )
100100 expect ( stdout ) . toEqual ( expect . stringContaining ( 'index' ) )
@@ -110,7 +110,7 @@ describe('cli', () => {
110110 '--no-ignore' , './test/fixtures'
111111 ] )
112112
113- expect ( exitCode ) . toBe ( 0 )
113+ expect ( exitCode ) . toBe ( 1 )
114114 expect ( stderr ) . toBe ( '' )
115115 expect ( stdout ) . toEqual ( expect . stringContaining ( '2x' ) )
116116 expect ( stdout ) . toEqual ( expect . stringContaining ( '1x' ) )
@@ -126,7 +126,7 @@ describe('cli', () => {
126126 '--no-ignore' , './test/fixtures'
127127 ] )
128128
129- expect ( exitCode ) . toBe ( 0 )
129+ expect ( exitCode ) . toBe ( 1 )
130130 expect ( stderr ) . toBe ( '' )
131131 expect ( stdout ) . toEqual ( expect . stringContaining ( '2x' ) )
132132 expect ( stdout ) . toEqual ( expect . not . stringContaining ( '1x' ) )
@@ -142,7 +142,7 @@ describe('cli', () => {
142142 '--no-ignore' , './test/fixtures'
143143 ] )
144144
145- expect ( exitCode ) . toBe ( 0 )
145+ expect ( exitCode ) . toBe ( 1 )
146146 expect ( stderr ) . toBe ( '' )
147147 expect ( stdout ) . toEqual ( expect . stringContaining ( '0: function' ) )
148148 } )
@@ -184,7 +184,7 @@ describe('cli', () => {
184184 } )
185185
186186 test ( 'multiple pipes' , async ( ) => {
187- const { stdout, stderr } = await new Promise ( ( resolve ) => {
187+ const { stdout, stderr, exitCode } = await new Promise ( ( resolve ) => {
188188 const eslint1 = spawn ( process . execPath , [
189189 './bin/eslint-multiplexer' ,
190190 'eslint' ,
@@ -218,11 +218,25 @@ describe('cli', () => {
218218 stderr += chunk
219219 } )
220220
221+ let exitCode
222+ let closedOrExited
221223 multiplexer . on ( 'close' , ( ) => {
222- resolve ( { stdout, stderr } )
224+ if ( closedOrExited ) {
225+ resolve ( { stdout, stderr, exitCode } )
226+ }
227+ closedOrExited = true
228+ } )
229+
230+ multiplexer . on ( 'exit' , ( code , signal ) => {
231+ exitCode = code
232+ if ( closedOrExited ) {
233+ resolve ( { stdout, stderr, exitCode } )
234+ }
235+ closedOrExited = true
223236 } )
224237 } )
225238
239+ expect ( exitCode ) . toBe ( 1 )
226240 expect ( stderr ) . toBe ( '' )
227241 expect ( stdout ) . toEqual ( expect . stringContaining ( '2x' ) )
228242 expect ( stdout ) . toEqual ( expect . stringContaining ( '1x' ) )
@@ -254,4 +268,17 @@ describe('cli', () => {
254268 expect ( stdout ) . toBe ( '' )
255269 expect ( stderr ) . toEqual ( expect . stringContaining ( 'There was a problem loading formatter' ) )
256270 } )
271+
272+ test ( 'exists with 0 status when no errors ' , async ( ) => {
273+ const { stdout, stderr, exitCode } = await spawnHelper ( [
274+ './bin/eslint-multiplexer' ,
275+ '--nopipe' ,
276+ 'eslint' ,
277+ '--no-ignore' , './test/fixtures/good.js'
278+ ] )
279+
280+ expect ( exitCode ) . toBe ( 0 )
281+ expect ( stderr ) . toBe ( '' )
282+ expect ( stdout ) . toBe ( '' )
283+ } )
257284} )
0 commit comments