File tree Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -216,6 +216,27 @@ const RunningTests: React.FC<{
216216 ) ;
217217} ;
218218
219+ const Exiter : React . FC < { done : boolean } > = ( { done } ) => {
220+ const { exit } = useApp ( ) ;
221+
222+ const [ shouldExit , setShouldExit ] = React . useState ( false ) ;
223+
224+ // use a separate effect to ensure output is properly flushed. This _might_ be a bug in Ink, not sure
225+ React . useEffect ( ( ) => {
226+ if ( done ) {
227+ setShouldExit ( true ) ;
228+ }
229+ } , [ done , exit ] ) ;
230+
231+ React . useEffect ( ( ) => {
232+ if ( shouldExit ) {
233+ exit ( ) ;
234+ }
235+ } , [ exit , shouldExit ] ) ;
236+
237+ return null ;
238+ } ;
239+
219240const Reporter : React . FC < Props > = ( {
220241 register,
221242 globalConfig,
@@ -246,13 +267,6 @@ const Reporter: React.FC<Props> = ({
246267 } = state ;
247268 const { estimatedTime = 0 } = options ;
248269
249- const { exit } = useApp ( ) ;
250- React . useEffect ( ( ) => {
251- if ( done ) {
252- setImmediate ( exit ) ;
253- }
254- } , [ done , exit ] ) ;
255-
256270 const summary = (
257271 < Summary
258272 aggregatedResults = { aggregatedResults }
@@ -277,6 +291,7 @@ const Reporter: React.FC<Props> = ({
277291 />
278292 < RunningTests tests = { currentTests } width = { width } />
279293 { done ? null : summary }
294+ < Exiter done = { done } />
280295 </ Box >
281296 ) ;
282297} ;
You can’t perform that action at this time.
0 commit comments