| 8 | boundStdoutHandler: (data: string) => void = this.stdoutHandler.bind(this); |
| 9 | |
| 10 | constructor(command: string) { |
| 11 | super(); |
| 12 | this.child = spawn(command, { shell: true }); |
| 13 | this.child.stdout?.on("data", this.boundStdoutHandler); |
| 14 | this.child.stderr?.on("data", this.boundStdoutHandler); |
| 15 | this.child.once("close", (code) => { |
| 16 | if (this.stdoutTimeout) { |
| 17 | clearTimeout(this.stdoutTimeout); |
| 18 | } |
| 19 | this.child.stdout?.off("data", this.boundStdoutHandler); |
| 20 | this.child.stderr?.off("data", this.boundStdoutHandler); |
| 21 | this.kill(); |
| 22 | this.emit("close", code); |
| 23 | }); |
| 24 | } |
| 25 | |
| 26 | get pid(): number { |
| 27 | return this.child.pid!; |