isaacs/npm — pull request #2189 by tylergreen (2012-02-22 19:11:14+00:00)
Title: fix #2187 set terminal columns to Infinity if 0

In some cases (like emacs shell, process.stdout.getWindowSize() returns [0,0])
In these cases, we should default to infinity because if cols == 0 blank lines are displayed.

I tested this fix in a xterm-color, xterm, vt102, vt100, vt52, rxvt, dtterm, ansi, emacs shell, and emacs terminal.

process.stdout.getWindowSize()[0]
I set the array index to 0 here because the c++ source code in node (file tty_wrap.cc) for GetWindowSize is

a->Set(0, Integer::New(width));
a->Set(1, Integer::New(height));

and we want the columns (width), not the rows(height).

Further justification for this fix:

the c++ source for tty.isatty just a guess. The node definition for IsTTY in tty_wrap.cc is

return uv_guess_handle(fd) == UV_TTY ? v8::True() : v8::False();