Run a series of gulp tasks in order.
Install with npm
npm install --save-dev gulp-sequence
vargulp=require('gulp')vargulpSequence=require('gulp-sequence')gulp.task('a',function(cb){//... cb()})gulp.task('b',function(cb){//... cb()})gulp.task('c',function(cb){//... cb()})gulp.task('d',function(cb){//... cb()})gulp.task('e',function(cb){//... cb()})gulp.task('f',function(){// return streamreturngulp.src('*.js')})// usage 1, recommend// 1. run 'a', 'b' in parallel;// 2. run 'c' after 'a' and 'b';// 3. run 'd', 'e' in parallel after 'c';// 3. run 'f' after 'd' and 'e'.gulp.task('sequence-1',gulpSequence(['a','b'],'c',['d','e'],'f'))// usage 2gulp.task('sequence-2',function(cb){gulpSequence(['a','b'],'c',['d','e'],'f',cb)})// usage 3gulp.task('sequence-3',function(cb){gulpSequence(['a','b'],'c',['d','e'],'f')(cb)})gulp.task('gulp-sequence',gulpSequence('sequence-1','sequence-2','sequence-3'))with gulp.watch:
gulp.watch('src/**/*.js',function(event){gulpSequence('a','b')(function(err){if(err)console.log(err)})})vargulpSequence=require('gulp-sequence')return a thunk function.
vargulp=require('gulp')vargulpSequence=require('gulp-sequence')gulp.task('test',gulpSequence(['a','b'],'c',['d','e'],'f'))return a new gulpSequence function with the gulp. If you have some errors such as "task xxx is not defined", this will resolve it.
vargulp=require('gulp')vargulpSequence=require('gulp-sequence').use(gulp)gulp.task('test',gulpSequence(['a','b'],'c',['d','e'],'f'))MIT © Teambition