Skip to content

Commit

Permalink
Clear down on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
lydell committed Aug 20, 2022
1 parent d603dbc commit 35c203d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"typescript": "4.7.4"
},
"scripts": {
"start": "node run-pty.js % cat % false % echo hello world % ping localhost % node get-cursor-position.js % node test-keys.js % node signals.js % node slow-kill.js % node slow-kill.js 2000 \"Shutting down…\" % make watch % make signals % node test-clear-down.js % node colored-log.js",
"start": "node run-pty.js % cat % false % echo hello world % ping localhost % node get-cursor-position.js % node test-keys.js % node signals.js % node slow-kill.js % node slow-kill.js 2000 \"Shutting down…\" % make watch % make signals % node test-clear-down.js % node colored-log.js % node test-exit-in-middle.js",
"example": "node run-pty.js example.json",
"auto-exit": "node run-pty.js --auto-exit=2 % sleep 3 % sleep 1 % sleep 2 % sleep 1 % sleep 1 && echo success",
"test": "node run-pty.js --auto-exit % prettier --check . % eslint . --report-unused-disable-directives % tsc % jest",
Expand Down
3 changes: 2 additions & 1 deletion run-pty.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ const exitTextAndHistory = ({ command, exitCode, numExited, numTotal }) => {
lastLine.trim() === "" ? "" : "\n";
return `
${commandTitleOnlyWithIndicator(exitIndicator(exitCode), command)}
${cwdText(command)}${command.history}${newline}${bold(
${cwdText(command)}${command.history}${CLEAR_DOWN}${newline}${bold(
`exit ${exitCode}`
)} ${dim(`(${numExited}/${numTotal} exited)`)}
Expand Down Expand Up @@ -1481,6 +1481,7 @@ const runInteractively = (commandDescriptions, autoExit) => {
HIDE_CURSOR +
RESET_COLOR +
disableAlternateScreen +
CLEAR_DOWN +
newlines +
(command.status.tag === "Waiting"
? waitingText(commands)
Expand Down
7 changes: 7 additions & 0 deletions test-exit-in-middle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";
for (let i = 0; i < 20; i++) {
console.log("stuff");
}
require("readline").moveCursor(process.stdout, 0, -10);
process.stdout.write("final print");
setTimeout(Function.prototype, 1000);

0 comments on commit 35c203d

Please sign in to comment.