2015-10-29 68 views
2

我需要依賴於我的「checkout」任務來等待git pull完成的任務。下面是我嘗試過,但它會在下面的任務,而無需等待結賬......不等待git pull完成的gulp依賴關係

var gulp = require('gulp'), git = require('gulp-git'); 

gulp.task('checkout', function() { 
    return git.pull('origin', 'Devel', { cwd: './source' }, function(err) { 
    if(err) { 
     gutil.log(err); 
    } 
    }); 
}); 

gulp.task('lint', ['checkout'], function() { 
    return gulp.src('./source/static.backyardfruit.com/js/backyardfruit/*.js') 
    .pipe(jshint()) 
    .pipe(jshint.reporter('jshint-stylish')) 
    .pipe(jshint.reporter('fail')); 
}); 

回答

2

的解決方案是在一口任務函數使用回調。這裏是工作代碼:

gulp.task('checkout', function(cb) { 
    git.pull('origin', 'Devel', { cwd: './source' }, function(err) { 
    if (err) return cb(err); 
    cb(); 
    }); 
}); 

gulp.task('lint', ['checkout'], function() { 
    return gulp.src('./source/static.backyardfruit.com/js/backyardfruit/*.js') 
    .pipe(jshint()) 
    .pipe(jshint.reporter('jshint-stylish')) 
    .pipe(jshint.reporter('fail')); 
});