MCPcopy
hub / github.com/vercel/next.js / constructor

Method constructor

turbopack/packages/devlow-bench/src/shell.ts:39–74  ·  view source on GitHub ↗
(private process: ChildProcess)

Source from the content-addressed store, hash-verified

37 exitPromise: Promise<number>
38 waitingForOutput: (() => void)[] = []
39 constructor(private process: ChildProcess) {
40 process.stdout?.pipe(split2()).on('data', (data) => {
41 const str = data.toString()
42 this.stdout += str + '\n'
43 this.output += str + '\n'
44 if (shellOutput) {
45 console.log(`[STDOUT] ${str}`)
46 }
47 if (this.waitingForOutput.length !== 0) {
48 const waitingForOutput = this.waitingForOutput
49 this.waitingForOutput = []
50 for (const fn of waitingForOutput) {
51 fn()
52 }
53 }
54 })
55 process.stderr?.pipe(split2()).on('data', (data) => {
56 const str = data.toString()
57 this.stderr += str + '\n'
58 this.output += str + '\n'
59 if (shellOutput) {
60 console.log(`[STDERR] ${str}`)
61 }
62 if (this.waitingForOutput.length !== 0) {
63 const waitingForOutput = this.waitingForOutput
64 this.waitingForOutput = []
65 for (const fn of waitingForOutput) {
66 fn()
67 }
68 }
69 })
70 this.exitPromise = new Promise<number>((resolve, reject) => {
71 process.on('error', reject)
72 process.on('exit', resolve)
73 })
74 }
75
76 async ok() {
77 const exitCode = await this.exitPromise

Callers

nothing calls this directly

Calls 5

fnFunction · 0.50
onMethod · 0.45
pipeMethod · 0.45
toStringMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected