Skip to content

Commit

Permalink
Handle process.stdout.columns being negative
Browse files Browse the repository at this point in the history
Adam Miskiewicz reported a RangeError raised when running on
macOS 10.12, with Node 8.6.  This would would have been caused by
process.stdout.columns returning a negative number.

If the value is negative, assume a width of 100 characters (as present
in spinner-progress.js).
  • Loading branch information
nwholloway committed Oct 16, 2017
1 parent 4c38ca7 commit 0ef88f7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/reporters/console/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const CLEAR_RIGHT_OF_CURSOR = 1;
export function clearLine(stdout: Stdout) {
if (!supportsColor) {
if (stdout instanceof tty.WriteStream) {
stdout.write(`\r${' '.repeat(stdout.columns - 1)}\r`);
const columns = stdout.columns > 0 ? stdout.columns : 100;
stdout.write(`\r${' '.repeat(columns - 1)}\r`);
}
return;
}
Expand Down

0 comments on commit 0ef88f7

Please sign in to comment.