chain-confirm-gulpfile.js 917 B

12345678910111213141516171819202122232425262728293031323334353637
  1. 'use strict';
  2. var gulp = require( 'gulp' );
  3. var prompt = require('../index');
  4. var index =0;
  5. var chainFunction = function ( options, resp ){
  6. console.log( 'Here is the selection ', resp);
  7. if( index <= 3){
  8. options.message = `Hello this is iteration ${index}`;
  9. index++;
  10. return options;
  11. }else{
  12. return;
  13. }
  14. };
  15. /**
  16. * The following is a sample gulp file for chaining requests. It
  17. * will pass a chaining function to the confirm function and will
  18. * allow the user to chain multiple requests together
  19. * variables
  20. *
  21. */
  22. gulp.task( 'chainConfirm', () => {
  23. return gulp.src( '../package.json' )
  24. .pipe( prompt.confirm({
  25. type:'input',
  26. name:'env',
  27. message:'Hello First interation, please enter selection?',
  28. chainFunction:chainFunction
  29. }, (res) => {
  30. console.log('Result', res);
  31. }) );
  32. });