You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To recreate, create the following file prompt-test.js, as a very simple test:
#!/usr/bin/env node
const prompt = require("prompt-sync")({"sigint": true})
for (var i = 0; i < 5; i++) {
console.log("Before prompt line")
var result = prompt("This is a test -- enter something >");
console.log("Result of prompt", result)
}
If run as ./prompt-test.js, it will ask for an input 5 times and print that output as you might expect.
However if you trying running echo hello world | ./prompt-test.js, the prompt itself is caught in a loop and repeats the prompt line and all previous inputs continually.
This might be happening because of my lack of understanding about Bash processes, sub-processes, or piping. Any help appreciated.
The text was updated successfully, but these errors were encountered:
This might have something to do with the reliance on process.stdin ... code suggests that's being used when process.platform === 'win32'. From the little I know, if a TTY readstream can be used instead, for example, it means piped input and keyboard input can be accepted and should work.
To recreate, create the following file
prompt-test.js
, as a very simple test:If run as
./prompt-test.js
, it will ask for an input 5 times and print that output as you might expect.However if you trying running
echo hello world | ./prompt-test.js
, the prompt itself is caught in a loop and repeats the prompt line and all previous inputs continually.This might be happening because of my lack of understanding about Bash processes, sub-processes, or piping. Any help appreciated.
The text was updated successfully, but these errors were encountered: