Skip to content

Commit

Permalink
fix(reporters): write buffered stdout/stderr on process exit
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Nov 19, 2024
1 parent f1babdc commit d9f70ec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
"magic-string": "^0.30.12",
"pathe": "^1.1.2",
"restore-cursor": "^5.1.0",
"signal-exit": "^4.1.0",
"std-env": "^3.8.0",
"tinybench": "^2.9.0",
"tinyexec": "^0.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Writable } from 'node:stream'
import type { Vitest } from '../../core'
import { stripVTControlCharacters } from 'node:util'
import restoreCursor from 'restore-cursor'
import { onExit } from 'signal-exit'

const DEFAULT_RENDER_INTERVAL = 16

Expand Down Expand Up @@ -54,6 +55,9 @@ export class WindowRenderer {
restoreCursor()
this.write(HIDE_CURSOR, 'output')

// Write buffered content on unexpected exits, e.g. direct `process.exit()` calls
onExit(() => this.flushBuffer())

this.start()
}

Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d9f70ec

Please sign in to comment.