0

My initial if statement does not come true by selecting 'gulp-studio'. The following code always outputs 'bye' into the console no matter my selection. I've tried a ton of different variants with no clue.

var gulp = require('gulp'),
    prompt = require('gulp-prompt'),
    gulpif = require('gulp-if'),
    shell = require('gulp-shell');

var response = 'response';

gulp.task('studio-wizard', function(){

return gulp.src(sourced.app, {read: false})
    .pipe(prompt.prompt([{
        type: 'checkbox',
        name: 'bump',
        message: 'Which version of Studi˚ would you like?',
        choices: ['gulp-studio', 'gulp-studio-vvv']
    }
    ], function(res){
        if (res.bump.indexOf("gulp-studio") > -1) {
            response = 'hello'
        } else {
             response = 'bye'
        }
    }));
});



gulp.task('generate-studio', ['studio-wizard'], function() {
return gulp.src(sourced.app)
    .pipe(shell([
  'echo' + ' ' + response 
]))
});

Can someone shed some light on how to solve this problem?

djfrsn
  • 191
  • 1
  • 11
  • This looks like the [everyday async problem](http://stackoverflow.com/questions/14220321/how-to-return-the-response-from-an-ajax-call). You'd have to work with callbacks or promises. – elclanrs Aug 24 '14 at 19:39
  • What value are you getting for `res.bump`? What were you expecting? – hugomg Aug 24 '14 at 19:45
  • I'll check out the link elclanrs. @hugomg res.bump is outputting: select. I was expecting an array of strings from res.bump containing gulp-studio/gulp-studio-vvv, the if else statement would then respond to that string. – djfrsn Aug 25 '14 at 01:03
  • I've tried your code and it works like expected. The console outputs *hello*. What versions of gulp-prompt and gulp-shell you are using? I use 0.6.4 and 0.2.9 May you can fix this by updating your dependencies? – RWAM Aug 27 '14 at 14:55

0 Answers0