| 147 | } |
| 148 | |
| 149 | class Display { |
| 150 | #logState = { |
| 151 | buffering: true, |
| 152 | buffer: [], |
| 153 | } |
| 154 | |
| 155 | #outputState = { |
| 156 | buffering: true, |
| 157 | buffer: [], |
| 158 | } |
| 159 | |
| 160 | // colors |
| 161 | #noColorChalk |
| 162 | #stdoutChalk |
| 163 | #stdoutColor |
| 164 | #stderrChalk |
| 165 | #stderrColor |
| 166 | #logColors |
| 167 | |
| 168 | // progress |
| 169 | #progress |
| 170 | |
| 171 | // options |
| 172 | #command |
| 173 | #levelIndex |
| 174 | #timing |
| 175 | #json |
| 176 | #heading |
| 177 | #silent |
| 178 | |
| 179 | // display streams |
| 180 | #stdout |
| 181 | #stderr |
| 182 | |
| 183 | #seenNotices = new Set() |
| 184 | |
| 185 | constructor ({ stdout, stderr }) { |
| 186 | this.#stdout = setBlocking(stdout) |
| 187 | this.#stderr = setBlocking(stderr) |
| 188 | |
| 189 | // Handlers are set immediately so they can buffer all events |
| 190 | process.on('log', this.#logHandler) |
| 191 | process.on('output', this.#outputHandler) |
| 192 | process.on('input', this.#inputHandler) |
| 193 | this.#progress = new Progress({ stream: stderr }) |
| 194 | } |
| 195 | |
| 196 | off () { |
| 197 | process.off('log', this.#logHandler) |
| 198 | this.#logState.buffer.length = 0 |
| 199 | process.off('output', this.#outputHandler) |
| 200 | this.#outputState.buffer.length = 0 |
| 201 | process.off('input', this.#inputHandler) |
| 202 | this.#progress.off() |
| 203 | this.#seenNotices.clear() |
| 204 | } |
| 205 | |
| 206 | get chalk () { |
nothing calls this directly
no test coverage detected