JSPM

  • Created
  • Published
  • Downloads 31794
  • Score
    100M100P100Q148965F
  • License MIT

Plugin for base-methods that adds methods for prompting the user and storing the answers on a project-by-project basis.

Package Exports

  • base-questions

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (base-questions) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

base-questions NPM version Build Status

Plugin for base-methods that adds methods for prompting the user and storing the answers on a project-by-project basis.

Install

Install with npm

$ npm i base-questions --save

Usage

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!');
});

API

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb on December 07, 2015.