
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
prompt-confirm
Advanced tools
Confirm (yes/no) prompt. Can be used standalone or with a prompt system like [Enquirer].
Confirm (yes/no) prompt. Can be used standalone or with a prompt system like Enquirer.
Install with npm:
$ npm install --save prompt-confirm
Question
Pass a string or question object to the constructor:
var Confirm = require('prompt-confirm');
var prompt = new Confirm('Do you like chocolate?');
// or
var prompt = new Confirm({
name: 'chocolate',
message: 'Do you like chocolate?'
});
Run the prompt
You can use one of the following two methods for running the prompt:
// async
prompt.ask(function(answer) {
console.log(answer);
});
// or promise
prompt.run()
.then(function(answer) {
console.log(answer);
});
Examples
var confirm = new Confirm('Like chocolate?')
.ask(function(answer) {
console.log(answer);
});
var confirm = new Confirm('Like chocolate?')
.run()
.then(function(answer) {
console.log(answer);
});
var Enquirer = require('enquirer');
var enquirer = new Enquirer();
enquirer.register('confirm', require('prompt-confirm'));
Enquirer supports either the declarative object-oriented (inquirer-style) question format or a more expressive format using the .question
method.
Declarative
Inquirer-style declarative format (takes an array or object):
var questions = [
{
type: 'confirm',
name: 'chocolate',
message: 'Like chocolate?'
},
{
type: 'confirm',
name: 'vanilla',
message: 'Like vanilla?'
}
];
enquirer.ask(questions)
.then(function(answers) {
console.log(answers)
});
Expressive
Pre-define questions and easily compose prompts by passing the name(s) of the prompts to run:
enquirer.question('chocolate', 'Like chocolate?', {type: 'confirm'});
enquirer.question('vanilla', 'Like vanilla?', {type: 'confirm'});
enquirer
.prompt(['chocolate', 'vanilla'])
.then(function(answers) {
console.log(answers)
});
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Jon Schlinkert
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on July 08, 2017.
FAQs
Confirm (yes/no) prompt. Can be used standalone or with a prompt system like [Enquirer].
The npm package prompt-confirm receives a total of 23,136 weekly downloads. As such, prompt-confirm popularity was classified as popular.
We found that prompt-confirm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.