idleberg idleberg - 1 year ago 161
Javascript Question

Gulp prompt to decide which tasks to run?

I have just discovered the gulp-prompt task. While it makes it easy to prompt the user in different ways, the examples don't hint at how to make use of the user's input. For instance I would like to offer two setups (e.g. CDN-hosted or local assets) to the user and run my tasks conditionally. How can you do that in Gulp? This could save me from looking into a Yeoman generator.

Answer Source


var inject = require('gulp-inject');
var cdnizer = require('gulp-cdnizer');
gulp.task('mytask', function(){
  var target = gulp.src('./src/index.html');
  return gulp.src('*')
        type: 'input',
        name: 'type',
        message: 'What you like to do? [cdn/assets]'
    }, function(res){
        var sources;
        if(res.type === 'cdn'){
          sources = ...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download