| 14 | // From: |
| 15 | // https://github.com/yarnpkg/yarn/blob/53d8004229f543f342833310d5af63a4b6e59c8a/src/reporters/console/util.js |
| 16 | export async function clearLine( |
| 17 | terminal: (typeof process)['stderr'] |
| 18 | ): Promise<void> { |
| 19 | if (!terminal.hasColors?.()) { |
| 20 | if (terminal.isTTY) { |
| 21 | // terminal |
| 22 | if (terminal.columns > 0) { |
| 23 | await writeStderr(`\r${' '.repeat(terminal.columns - 1)}`) |
| 24 | } |
| 25 | await writeStderr(`\r`) |
| 26 | } |
| 27 | // ignore piping to file |
| 28 | } else { |
| 29 | nativeClearLine(terminal, CLEAR_WHOLE_LINE) |
| 30 | nativeCursorTo(terminal, 0, undefined) |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | type LogLevel = 'debug' | 'warn' | 'error' |
| 35 | |