
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
base-questions
Advanced tools
Plugin for base-methods that adds methods for prompting the user and storing the answers on a project-by-project basis.
Plugin for base-methods that adds methods for prompting the user and storing the answers on a project-by-project basis.
You might also be interested in data-store.
(TOC generated by verb using markdown-toc)
Install with npm:
$ npm install --save base-questions
Try running the actual examples if it helps to see the following example in action.
var questions = require('base-questions');
var assemble = require('assemble-core');
var store = require('base-store');
var argv = require('base-argv');
var app = assemble();
app.use(store());
app.use(argv());
var argv = app.argv(process.argv.slice(2));
app.use(questions(app, argv.options));
app.task('ask', function (cb) {
app.ask(function (err, answers) {
if (err) return cb(err);
console.log(answers);
cb();
});
});
app.task('a', function (cb) {
console.log('task > a!');
cb();
});
app.task('b', function (cb) {
console.log('task > b!');
cb();
});
app.task('c', function (cb) {
console.log('task > c!');
cb();
});
app.task('choices', function (cb) {
app.choices('run', ['a', 'b', 'c'], function (err, answers) {
if (err) return cb(err);
if (!answers.run.length) return cb();
app.build(answers.run, cb);
});
});
app.build('choices', function(err) {
if (err) return console.log(err);
console.log('done!');
});
Create a confirm
question.
Params
name
{String}: Question namemsg
{String}: Question messagequeue
{String|Array}: Name or array of question names.options
{Object|Function}: Question options or callback functioncallback
{Function}: callback functionExample
app.confirm('file', 'Want to generate a file?');
// equivalent to
app.question({
name: 'file',
message: 'Want to generate a file?',
type: 'confirm'
});
Create a "choices" question from an array.
Params
name
{String}: Question namemsg
{String}: Question messagechoices
{Array}: Choice itemsqueue
{String|Array}: Name or array of question names.options
{Object|Function}: Question options or callback functioncallback
{Function}: callback functionExample
app.choices('color', 'Favorite color?', ['blue', 'orange', 'green']);
// or
app.choices('color', {
message: 'Favorite color?',
choices: ['blue', 'orange', 'green']
});
// or
app.choices({
name: 'color',
message: 'Favorite color?',
choices: ['blue', 'orange', 'green']
});
Add a question to be asked by the .ask
method.
Params
name
{String}: Question namemsg
{String}: Question messagevalue
{Object|String}: Question object, message (string), or options object.locale
{String}: Optionally pass the locale to use, otherwise the default locale is used.returns
{Object}: Returns the this.questions
object, for chainingExample
app.question('beverage', 'What is your favorite beverage?');
// or
app.question('beverage', {
type: 'input',
message: 'What is your favorite beverage?'
});
// or
app.question({
name: 'beverage'
type: 'input',
message: 'What is your favorite beverage?'
});
Ask one or more questions, with the given options
and callback.
Params
queue
{String|Array}: Name or array of question names.options
{Object|Function}: Question options or callback functioncallback
{Function}: callback functionExample
// ask all questions
app.ask(function(err, answers) {
console.log(answers);
});
// ask the specified questions
app.ask(['name', 'description'], function(err, answers) {
console.log(answers);
});
choices
question types: checkbox… more | homepagePull requests and stars are always welcome. For bugs and feature requests, please create an issue.
(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)
To generate the readme and API documentation with verb:
$ npm install -g verb verb-generate-readme && verb
Install dev dependencies:
$ npm install -d && npm test
Jon Schlinkert
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb-generate-readme, v0.1.31, on October 01, 2016.
FAQs
Plugin for base-methods that adds methods for prompting the user and storing the answers on a project-by-project basis.
The npm package base-questions receives a total of 30,856 weekly downloads. As such, base-questions popularity was classified as popular.
We found that base-questions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.