File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -151,6 +151,14 @@ describe('#start()', () => {
151151 expect ( command . state ) . toBe ( 'exited' ) ;
152152 } ) ;
153153
154+ it ( 'does not change state if there was an error' , ( ) => {
155+ const { command } = createCommand ( ) ;
156+ command . start ( ) ;
157+ process . emit ( 'error' , 'foo' ) ;
158+ process . emit ( 'close' , 0 , null ) ;
159+ expect ( command . state ) . toBe ( 'errored' ) ;
160+ } ) ;
161+
154162 it ( 'shares start and close timing events to the timing stream' , async ( ) => {
155163 const { command, values } = createCommand ( ) ;
156164 const startDate = new Date ( ) ;
Original file line number Diff line number Diff line change @@ -169,7 +169,11 @@ export class Command implements CommandInfo {
169169 . pipe ( Rx . map ( ( event ) => event as [ number | null , NodeJS . Signals | null ] ) )
170170 . subscribe ( ( [ exitCode , signal ] ) => {
171171 this . process = undefined ;
172- this . state = 'exited' ;
172+
173+ // Don't override error event
174+ if ( this . state !== 'errored' ) {
175+ this . state = 'exited' ;
176+ }
173177
174178 const endDate = new Date ( Date . now ( ) ) ;
175179 this . timer . next ( { startDate, endDate } ) ;
You can’t perform that action at this time.
0 commit comments