我需要一个依赖于我的'checkout'任务的任务来等待git pull完成。这是我尝试过的,但它不用等待结账就继续执行以下任务......
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'));
});
答案 0 :(得分:2)
解决方案是在gulp任务函数中使用回调。这是工作代码:
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'));
});