Permalink
Browse files

Allow up to be invoked outside of a tty

  • Loading branch information...
1 parent 43063c6 commit 3ee3754887c43791b2db42b614d65837b7633647 @shinuza shinuza committed Mar 5, 2012
Showing with 17 additions and 15 deletions.
  1. +17 −15 bin/up
View
32 bin/up
@@ -172,22 +172,24 @@ process.on('SIGUSR2', function () {
* Listen on control+r
*/
-process.stdin.resume();
-tty.setRawMode(true);
-process.stdin.on('keypress', function (char, key) {
- if (key.ctrl) {
- switch (key.name) {
- case 'c':
- process.exit();
- break;
-
- case 'r':
- debug('\033[97mctrl + r\033[90m detected - reloading');
- srv.reload();
- break;
+if(tty.isatty(process.stdin)) {
@TooTallNate

TooTallNate Jun 21, 2012

Contributor

tty.isatty() expects a file descriptor (a Number), not a Stream instance.

So in this case you'd do tty.isatty(0).

@shinuza

shinuza Jun 21, 2012

Contributor

Shouldn't be process.stdin.fd?

+ process.stdin.resume();
+ tty.setRawMode(true);
+ process.stdin.on('keypress', function (char, key) {
+ if (key.ctrl) {
+ switch (key.name) {
+ case 'c':
+ process.exit();
+ break;
+
+ case 'r':
+ debug('\033[97mctrl + r\033[90m detected - reloading');
+ srv.reload();
+ break;
+ }
}
- }
-});
+ });
+}
/**
* Watch.

0 comments on commit 3ee3754

Please sign in to comment.