Questions tagged [inquirerjs]

Use this tag for questions related to the Inquirer JavaScript package, which provides a command line interface for Node.js.

The Documentation section of the package's GitHub README provides examples of usage, as well as links to various plugins.

43 questions
6
votes
2 answers

How to write unit tests for Inquirer.js?

I was wondering how to write unit tests for the npm package Inquirer.js, which is a tool to make CLI package more easily. I have read this post but I was't able to make it works. Here is my code that needs to be tested: const questions = [ …
5
votes
1 answer

How do I register an inquirer.js plugin for a yeoman generator prompt?

When authoring a yeoman generator, I'd like to use the 'autocomplete' plugin for inquirer (https://github.com/mokkabonna/inquirer-autocomplete-prompt) in one of my prompts. I can't seem to find anything in the docs that says how to register this…
Ben
  • 14,789
  • 19
  • 67
  • 115
4
votes
1 answer

How do I dynamically add questions to Inquirer JS during execution, using rxjs?

I want to ask questions to the user without having all the questions lined up immediately. The documentation mentions rxjs but I feel there is a gap in the documentation on how to properly add questions while prompts are being executed, or at least…
William Bernting
  • 421
  • 3
  • 12
3
votes
1 answer

Send a string and Enter key to a Node.js script from command line

I am running a Node.js script in Linux that prompts (via lib) user for a code. I get the process id of the script: pgrep -f test.js and then pass it the code with a new line to simulate Enter key: echo -e "1234\n" > /proc/88888/fd/0 The code 1234…
Haris ur Rehman
  • 2,391
  • 27
  • 39
3
votes
0 answers

Using node-inspect with inquirer

I am trying to use node-inspect to debug an application that uses inquirer. If I run: node app.js I get asked the first question for my app. I then use the keyboard to enter my answer and hit enter to continue. My issue is when Run node-inspect…
Ian Jamieson
  • 3,511
  • 1
  • 28
  • 49
2
votes
2 answers

How to clear wrong input in Inquirer.js

const inquirer = require("inquirer") var questions = [ { type: "number", name: "name", message: "Please the number of players", validate: function (name) { var valid = Number.isInteger(name) return valid || `Please…
2
votes
1 answer

Running several Axios requests in parallel to validate data

I'm using Inquirer.js to interact with a user. In one of the dialogs, the user can specify a comma-separated list of "items". The following validation function checks against an API, whether the "item" is available. If not, the user is prompted to…
idleberg
  • 10,319
  • 7
  • 36
  • 57
1
vote
0 answers

How To Debug Node CLI (Interactive Prompts with Inquirer) With VS Code?

I have a Node CLI built with Commander and Inquirer. I'm currently trying to debug the application using VS Code. My current launch.json configuration: { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions…
StephenWeiss
  • 143
  • 1
  • 9
1
vote
1 answer

How to pass parameters to a inquirer question?

How to pass parameters to the inquirer questions, so that i can set the values of a question object based on either values from previous questions or from code outside the prompt? The only way i can see of achieving this if based on answer of a…
vostok
  • 45
  • 5
1
vote
1 answer

How can I start an interactive bash script from a node app?

I'm building a command-line app in Node which is basically a setup wizard. At some point in the script, I'd like to start an openssl script which has its own stdout and prompts, and then ideally return to my Node app when it's done. I've tried using…
Shruggie
  • 640
  • 4
  • 18
1
vote
0 answers

inquirer package, present questions based on previous answers

I'm using NPM 'inquirer' package in order to present the user various questions. One of them is a 'choices' selection. Is there a way to present follow up questions based on the 'choices' selection? Here's my code: const { prompt } =…
David Faizulaev
  • 2,471
  • 13
  • 42
  • 78
1
vote
1 answer

How to generate value by first npm script and pass it dynamically to second npm script

I am trying to create something like custom launcher for my testing framework using inquirer.js. I want to run inquirer by npm script and select values from list and on the end generate url and pass this url to my test which is run by second npm…
vott
  • 53
  • 5
1
vote
0 answers

Inquirer.js: ask multiple questions if one prompt is true

I'm writing an account creator using Inquirer.js, and wanted to ask for the user's e-mail and password only if the user asked for such protection. It goes like this: inquirer.prompt([ {type:'input', name:'username', message:'Choose an…
Salies
  • 21
  • 5
1
vote
0 answers

running into unhandled promise error with inquirer checkbox

So I'm writing a node CLI application which consists of a card playing game where the user draws 5 cards and then has a choice to get rid of up to 4 cards in his hand. I am writing this in Javascript and I'm using the following npm modules…
1
vote
1 answer

Repeat set of questions in InquirerJS

Is there a way to reset the questions or have a certain answer direct the question to another previous question? var questions = [{ { name: 'morefood', message: 'Do you want more food?', type: 'list', choices: [ 'Yes', 'No'], },{ name:…
ronsic
  • 181
  • 2
  • 11
1
2 3