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<{
216
216
) ;
217
217
} ;
218
218
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
+
219
240
const Reporter : React . FC < Props > = ( {
220
241
register,
221
242
globalConfig,
@@ -246,13 +267,6 @@ const Reporter: React.FC<Props> = ({
246
267
} = state ;
247
268
const { estimatedTime = 0 } = options ;
248
269
249
- const { exit } = useApp ( ) ;
250
- React . useEffect ( ( ) => {
251
- if ( done ) {
252
- setImmediate ( exit ) ;
253
- }
254
- } , [ done , exit ] ) ;
255
-
256
270
const summary = (
257
271
< Summary
258
272
aggregatedResults = { aggregatedResults }
@@ -277,6 +291,7 @@ const Reporter: React.FC<Props> = ({
277
291
/>
278
292
< RunningTests tests = { currentTests } width = { width } />
279
293
{ done ? null : summary }
294
+ < Exiter done = { done } />
280
295
</ Box >
281
296
) ;
282
297
} ;
You can’t perform that action at this time.
0 commit comments