Questions tagged [inquirer]

60 questions
8
votes
4 answers

Is there a way to use previous answers in inquirer when presenting a prompt (inquirer v6)?

So what I want to do is use a previous answer when asking a question further down the line. Basically so that I can show a summary of what will be created and ask for a verification. this.prompt([ { type: 'input', name: 'name', …
5
votes
1 answer

How to terminate npm inquirer prompt and return control to main menu/function

I keep running into an issue with the inquirer npm package and cant find a solution anywhere. I am trying to allow a user to exit the inquirer prompt in a function at any point and return to the main menu. However, it seems this is causing multiple…
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

How to set default value for an answer using inquirer?

I am trying to create a small build script which will ask the user for the location to the mysql headers if they are not found in the default path. Right now I am using inquirer to prompt the user for input which works fine, but I have encountered…
Cyclonecode
  • 26,179
  • 11
  • 66
  • 86
3
votes
1 answer

What is the difference between 'List' and 'Rawlist' when using Inquirer

I'm using inquirer and I can either make a 'list' type or a 'rawlist' type. My goal is to allow the user to select an item from an array of products from a sql database, but I am now curious what the difference between these two list types are? In…
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

ORA Spinner stops on CLI with Inquirer.js

Don't know what to title the question but I will try my best to convey in the rest of the question. I am developing a CLI which first prompt user for a few questions and clone a repository based on the answers. Example: Frontend Framework: [x] Vue […
2
votes
0 answers

@oclif/test with `inquirer.prompt`

I am trying to test my entire cli dialogs using oclif and @oclif/test. Prompts are made with inquirer. Everything work fine, except the use of the .stdin( mock. Feature extract looks like this: ... const { sessionToken } = await inquirer.prompt([{ …
Slim
  • 996
  • 1
  • 8
  • 20
2
votes
1 answer

Unit testing Inquirer with Jest

I've been trying to understand searching various forums, but could not get to what I'm looking for. Partly because of my NodeJS ignorance. I'm just starting up. My task is to unit test inquirer based CLI via Jest/Mocha. How do I mock and test…
2
votes
1 answer

Trigger input on Gitlab Ci

I'm so curious about trigger input on gitlab CI pipeline *cmiiw. So, the main problem when there's any prompt on Node.js like this, Ubuntu But when i'm trying to implementation into Gitlab CI, there's any error something like this Gitlab.CI This…
1
vote
1 answer

How can I auto answer questions in inquirer.js?

I'm writing a small CLI in typescript and I have a command which basically allows me to generate a json file with default values in it (just like npm init -y), but I don't know how to auto answer the questions in inquirer. This is what I've got so…
kmp
  • 319
  • 9
1
vote
1 answer

Parametizing table name Node.js/mySQL?

So I have three mySQL database tables that I need to be able to add records to from inquirer. Rather than write three separate functions, I'd like to just have one efficient function that can do all three depending on the input. The user is asked…
1
vote
1 answer

Import Inquirer as module in Node 13

I'm having troubles with import of Inquirer using modules in Node 13.12.0. Any other import works well. As long as I've been using Node 12.x with require() it worked well. My use-case of anything.mjs import fs from "fs"; // works well import…
Jax-p
  • 3,178
  • 12
  • 33
1
vote
1 answer

How to test async code with Jest without passing it as a callback?

Will be grateful if someone could clarify to me how test the async code from inquirer plugin for CLI app. The module exports updateView function, which calls async inquirer.prompt inside. const inquirer = require("inquirer"); const getAnswer =…
1
vote
1 answer

How do you test inquirer CLIS?

I would like to write units tests for a CLI I made in inquirer. I want to verify that the prompts are displayed correctly, simulate choices in the command line, and verify that the resonses are correct.
Toli
  • 4,534
  • 5
  • 30
  • 46
1
2 3 4