runSequence不兼容gulp?

时间:2015-09-16 22:14:46

标签: javascript reactjs gulp

runsequence下面的代码是不是很有效?

var gulp = require('gulp');
var del = require('del');
var browserify = require('gulp-browserify');
var concat = require('gulp-concat');
var runSequence = require('run-sequence');
var nodemon = require('gulp-nodemon');

gulp.task('clean', function(cb) {
  console.log('YOLO1');
  del(['build/*'], cb);
});

gulp.task('copy', function() {
 console.log('YOLO2')
 return gulp.src('client/www/index.html')
    .pipe(gulp.dest('build'));
});

gulp.task('browserify', function() {
  console.log('YOLO3')
  return gulp.src('client/index.js')
    .pipe(browserify({transform: 'reactify'}))
    .pipe(concat('app.js'))
    .pipe(gulp.dest('build'));
});

gulp.task('build', function(cb) {
  console.log('YOLO4')
  runSequence('clean', 'browserify', 'copy', cb);
});

gulp.task('default', ['build'], function() {
  gulp.watch('client/*/*', ['build']);
  nodemon({ script: './bin/www', ignore: ['gulpfile.js', 'build', 'client', 'dist'] });
});

当前输出:

YOLO4,
YOLO1

渴望输出:

 YOLO4,
 YOLO1,
 YOLO3,
 YOLO2

我不确定为什么runSequence只执行第一个任务而无法执行其余任务?任何想法?

1 个答案:

答案 0 :(得分:8)

del不接受回调,但会同步返回:(请参阅https://github.com/gulpjs/gulp/blob/master/docs/recipes/delete-files-folder.md中的第一个示例)

gulp.task('clean', function() {
  console.log('YOLO1');
  return del(['build/*']);
});