Skip to content

Commit

Permalink
fix(watch): clear screen on all terminals
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Jun 25, 2023
1 parent 5edc55f commit 24751d7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/vitest/src/node/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import { RandomSequencer } from './sequencers/RandomSequencer'
import type { Vitest } from './core'
import { printError } from './error'

// https://www.real-world-systems.com/docs/ANSIcode.html
const ESC = '\x1B['
const ERASE_SCREEN = `${ESC}2J`
const ERASE_SCROLLBACK = `${ESC}3J`
const CURSOR_HOME_ROW = `${ESC}H`

export class Logger {
outputStream = process.stdout
errorStream = process.stderr
Expand Down Expand Up @@ -43,7 +49,8 @@ export class Logger {
return
}

this.console.log(`\x1Bc${message}`)
this.console.log(`${ERASE_SCREEN}${ERASE_SCROLLBACK}${CURSOR_HOME_ROW}`)
this.console.log(message)
}

clearScreen(message: string, force = false) {
Expand Down

0 comments on commit 24751d7

Please sign in to comment.