(options = {})
| 32 | EXIT_ALTERNATE_SCREEN_SEQUENCE + SAFE_TERMINAL_RESET_SEQUENCES |
| 33 | |
| 34 | function resetTerminal(options = {}) { |
| 35 | const { exitAlternateScreen = false } = options |
| 36 | |
| 37 | try { |
| 38 | if (process.stdin.isTTY && process.stdin.setRawMode) { |
| 39 | process.stdin.setRawMode(false) |
| 40 | } |
| 41 | } catch { |
| 42 | // stdin may be closed |
| 43 | } |
| 44 | try { |
| 45 | if (process.stdout.isTTY) { |
| 46 | // Exiting the alternate screen is only safe after an interactive child. |
| 47 | // Plain CLI paths like --help never enter it, and ?1049l can erase output. |
| 48 | process.stdout.write( |
| 49 | exitAlternateScreen |
| 50 | ? FULL_TERMINAL_RESET_SEQUENCES |
| 51 | : SAFE_TERMINAL_RESET_SEQUENCES, |
| 52 | ) |
| 53 | } |
| 54 | } catch { |
| 55 | // stdout may be closed |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | function getUnsignedExitCode(code) { |
| 60 | return code != null && code < 0 ? (code >>> 0) : code |
no outgoing calls
no test coverage detected