MeteorJS: how to read stdin from terminal?

Can stdin be read from terminal in Meteor app? I want to run some prompts using Node readline .

I tried the example on the readline page, but I get a prompt printed to the terminal without waiting for a response:

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

rl.question("What do you think of node.js? ", function(answer) {
  // TODO: Log the answer in a database
  console.log("Thank you for your valuable feedback:", answer);

  rl.close();
});

      

This code works fine in a normal NodeJS script.

Related tickets:

+3


source to share





All Articles