yn-prompt
v1.0.7
Published
NodeJS module.
Downloads
5
Readme
yn-prompt
NodeJS module.
When input yes or no, use this yn-prompt module.
Its dependency is the prompt module.
##installation
npm i yn-prompt
##api
ynPrompt( msg, pattern );
##usecase1
var ynPrompt = require('yn-prompt');
ynPrompt("Do you want to copy node_modules directory into the release folder?(y/n)").then( function( yn ) {
if( yn.toUpperCase() !== 'Y' ) return;
return ynPrompt("Do you want devDependency?(y/n)");
}).then( function( yn ) {
if( yn.toUpperCase() !== 'Y' ) {
// todo: copy both devDependencies and dependencies
} else {
// todo: copy only dependencies
}
});
##usecase2 with gulp
var gulp = require('gulp');
var ynPrompt = require('yn-prompt');
var goContinue = false;
gulp.task('question', function( done ) {
var result = syncExec('svn status');
console.warn( result.stdout );
ynPrompt('Check the uncommited files. continue? (y/n)').then(( yn ) => {
if( yn.toUpperCase() === 'Y' ) {
goContinue = true;
}
done();
});
});
gulp.task('preversion',['question'], function( done ) {
if( ! goContinue ) {
logger.info('canceled version up process');
throw { errorDesc: 'canceled version up process' };
}
done();
});