1.0.2 • Published 7 years ago

composer-confirm v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

composer-confirm NPM version NPM monthly downloads NPM total downloads Linux Build Status

Uses prompt-confirm to conditionally run composer tasks based on responses to prompts. Can also be used with assemble, generate, verb and update (instead of composer).

Install

Install with npm:

$ npm install --save composer-confirm

Usage

var Composer = require('composer');
var composer = new Composer();

// pass an instance of composer and optional fn
// if `fn` is passed it will be called with the prompt
// instance before running the prompt
var confirm = require('composer-confirm')(composer, fn);
confirm(taskName, message, yesCallback, noCallback);

Examples

Callbacks for yes and no can be any valid argument to a composer task.

Functions

confirm('default', 'Want to run this?', function(cb) {
  console.log('YES!!! :)');
  cb();
}, function(cb) {
  console.log('NO?!! :(');
  cb();
});

No-op

Simulate a no-op task by passing an empty array.

confirm('default', 'Want to run this?', [], function(cb) {
  console.log('NO?!! :(');
  cb();
});

Task names

app.task('yes', function(cb) {
  console.log('YES!!! :)');
  cb();
})

app.task('no', function(cb) {
  console.log('NO?!! :(');
  cb();
})

confirm('default', 'Want to run this?', 'yes', 'no');

Arrays of task names

app.task('yes', function(cb) {
  console.log('YES!!! :)');
  cb();
});

app.task('and', function(cb) {
  cb();
})

app.task('no', function(cb) {
  console.log('NO?!! :(');
  cb();
});

app.task('but', function(cb) {
  cb();
});

confirm('default', 'Want to run this?', ['yes', 'and'], ['no', 'but']);

About

Related projects

  • assemble: Get the rocks out of your socks! Assemble makes you fast at creating web projects… more | homepage
  • enquirer: Intuitive, plugin-based prompt system for node.js. | homepage
  • generate: Command line tool and developer framework for scaffolding out new GitHub projects. Generate offers the… more | homepage
  • update: Be scalable! Update is a new, open source developer framework and CLI for automating updates… more | homepage
  • verb: Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… more | homepage

Contributing

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

Please read the contributing guide for advice on opening issues, pull requests, and coding standards.

Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

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

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on June 02, 2017.