heapwolf / prompt-sync

a synchronous prompt for node.js
MIT License
218 stars 42 forks source link

fails in node 0.10 on OS X #8

Closed davidmarkclements closed 8 years ago

davidmarkclements commented 8 years ago

this is due to reading from /dev/stdin

/usr/bin/tty will output the current tty e.g. /dev/ttys006 - this can be used instead, but spawning /usr/bin/tty has to be done async on node 0.10 - which means there would be an async setup step.

$ node --version
v0.10.40
$ node -e "require('prompt-sync').prompt()"

fs.js:488
  var r = binding.read(fd, buffer, offset, length, position);
                  ^
Error: EAGAIN, resource temporarily unavailable
    at Object.fs.readSync (fs.js:488:19)
    at Object.prompt (/Users/davidclements/z/nearForm/fuge/fuge/node_modules/prompt-sync/index.js:54:15)
    at [eval]:1:24
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:456:26)
    at evalScript (node.js:565:25)
    at startup (node.js:80:7)
    at node.js:935:3
davidmarkclements commented 8 years ago

you can point at /dev/tty instead of /dev/stdin and this problem goes away..

need to confirm for linux

davidmarkclements commented 8 years ago

have a solution: PR here: https://github.com/0xxff/prompt-sync/pull/9