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('{%= name %}')(composer, fn);
confirm(taskName, message, yesCallback, noCallback);
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']);