/
dot.ts
46 lines (39 loc) · 1.3 KB
/
dot.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import type { UserConsoleLog } from '../../types'
import { setTimeout } from '../../utils'
import { BaseReporter } from './base'
import { createDotRenderer } from './renderers/dotRenderer'
import type { createListRenderer } from './renderers/listRenderer'
export class DotReporter extends BaseReporter {
renderer?: ReturnType<typeof createListRenderer>
onCollected() {
if (this.isTTY) {
const files = this.ctx.state.getFiles(this.watchFilters)
if (!this.renderer)
this.renderer = createDotRenderer(files, { outputStream: this.ctx.outputStream }).start()
else
this.renderer.update(files)
}
}
async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
await this.stopListRender()
this.ctx.log()
await super.onFinished(files, errors)
}
async onWatcherStart() {
await this.stopListRender()
super.onWatcherStart()
}
async stopListRender() {
this.renderer?.stop()
this.renderer = undefined
await new Promise(resolve => setTimeout(resolve, 10))
}
async onWatcherRerun(files: string[], trigger?: string) {
await this.stopListRender()
await super.onWatcherRerun(files, trigger)
}
onUserConsoleLog(log: UserConsoleLog) {
this.renderer?.clear()
super.onUserConsoleLog(log)
}
}