Lookup the current process's TTY device
Get the TTY device (e.g., /dev/pts/3) of the current node process
// A clone of the `tty` commandvar tty = require'spotty';ttyif errconsole.error"Error found: " + errtoStringelseconsole.logres
It's an ugly hack, but it should work. The idea is to call
file descriptor 0, and then to call
stat on all
tty-like files in dev.
Stop when we find one that matches
Doesn't work on Windows. Should work on OSX and Linux, but needs some testing. Won't work if fd=0 isn't standard input connected to a TTY.
Max Krohn for Keybase, Inc.