Inquirer.js: InquirerJS in sync mode

Created on 1 Oct 2014  路  3Comments  路  Source: SBoudrias/Inquirer.js

Can run InquirerJS in sync mode?

Example:

var answers = inquirer.prompt([...]);

Most helpful comment

@AdrienHorgnies Yeah, common in a lot of languages, but Node.js doesn't have a synchronous Readline module https://nodejs.org/api/readline.html - so unfortunately, this isn't possible.

That being said, you can leverage the await/async functions to get a similar style

const { name } = await inquirer.prompt();

All 3 comments

Nope. As we ask for user input, there's no way to block processing and make it synchronous.

@SBoudrias Why is that ? I don't quite get it, ask user input synchronously is what I'd do in many languages. The case where you wait for user input and cannot do anything without it is pretty common.

@AdrienHorgnies Yeah, common in a lot of languages, but Node.js doesn't have a synchronous Readline module https://nodejs.org/api/readline.html - so unfortunately, this isn't possible.

That being said, you can leverage the await/async functions to get a similar style

const { name } = await inquirer.prompt();
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mrooze-zeng picture Mrooze-zeng  路  5Comments

Ezekiel-DA picture Ezekiel-DA  路  7Comments

aydn picture aydn  路  5Comments

mechanical-turk picture mechanical-turk  路  3Comments

aaronshaf picture aaronshaf  路  7Comments