MCPcopy
hub / github.com/vitest-dev/vitest / constructor

Method constructor

test/test-utils/cli.ts:17–40  ·  view source on GitHub ↗
(options: { stdin: ReadableOrWritable; stdout: ReadableOrWritable; stderr: ReadableOrWritable; preserveAnsi?: boolean })

Source from the content-addressed store, hash-verified

15 private preserveAnsi?: boolean
16
17 constructor(options: { stdin: ReadableOrWritable; stdout: ReadableOrWritable; stderr: ReadableOrWritable; preserveAnsi?: boolean }) {
18 this.stdin = options.stdin
19 this.stdin = options.stdin
20 this.preserveAnsi = options.preserveAnsi
21
22 for (const source of (['stdout', 'stderr'] as const)) {
23 const stream = options[source]
24
25 if ((stream as Readable).readable) {
26 stream.on('data', (data) => {
27 this.capture(source, data)
28 })
29 }
30 else if (isWritable(stream)) {
31 const original = stream.write.bind(stream)
32
33 // @ts-expect-error -- Is there a better way to detect when a Writable is being written into?
34 stream.write = (data, encoding, callback) => {
35 this.capture(source, data)
36 return original(data, encoding, callback)
37 }
38 }
39 }
40 }
41
42 private capture(source: Source, data: any) {
43 const msg = this.preserveAnsi ? data.toString() : stripVTControlCharacters(data.toString())

Callers

nothing calls this directly

Calls 4

captureMethod · 0.95
isWritableFunction · 0.85
bindMethod · 0.80
onMethod · 0.45

Tested by

no test coverage detected