Skip to content

base-repos/task-prompts

Repository files navigation

task-prompts NPM version NPM downloads Build Status

User prompts for conditionally running tasks.

Install

Install with npm:

$ npm install task-prompts --save

Usage

Heads up! This is not a plugin, but the main export is a function that takes an instance of base and an options object. Requires the base-task and base-questions plugins to be registered first.

var prompts = require('task-prompts');
var questions = require('base-questions');
var task = require('base-task');
var Base = require('base');
var app = new Base();

var ask = prompts(app);
app.use(questions());
app.use(task());

Examples

Conditionally run tasks

To run this example, you will also need to use the base-npm plugin.

var npm = require('base-npm');
app.use(npm());

// run `a` if truthy, otherwise `b`
app.task('foo', ask.confirm('Want to install `foo`?', ['a'], ['b']));

Conditionally call functions

To run this example, you will also need to use the base-npm plugin.

// calls the `yes` function if the answer is truthy, otherwise `no`
app.task('basic', prompt.confirm('Want to do stuff?', yes, no));

function yes(cb) {
  console.log('yes!');
  cb();
}

function no(cb) {
  console.log('no!');
  cb();
}

Contributing

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

Building docs

Generate readme and API documentation with verb:

$ npm install verb && npm run docs

Or, if verb is installed globally:

$ verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2016, Jon Schlinkert. Released under the MIT license.


This file was generated by verb, v0.9.0, on April 22, 2016.

About

User prompts for conditionally running tasks.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

  •  
  •  

Packages

No packages published