I'm proggraming in the MEAN stack , so I have my app.js and I want to build a process which will take commands from the shell its running on (process.stdin)
Currently I have tried :
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('What do you think of Node.js? ', (answer) => {
// TODO: Log the answer in a database
console.log(`Thank you for your valuable feedback: ${answer}`);
rl.close();
});
but it writes my input twice and exit after 1 line .
I need a readline function that will loop and take infinite commands from me .
How can I get it ?
via Zed Evans
No comments:
Post a Comment