使用带有indexOf()的if语句在Gulp中传递字符串,if else语句总是返回false?

时间:2014-08-24 19:33:10

标签: javascript string if-statement gulp

通过选择'gulp-studio',我的初始if语句无法实现。无论我选择什么,以下代码总是将“再见”输出到控制台。我已经尝试了很多不同的变种,但没有任何线索。

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 
]))
});

有人可以解释如何解决这个问题吗?

0 个答案:

没有答案