Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run gulp tasks sequentially? [duplicate]

I have a few tasks in gulp and all of them except one could be run in parallel. Let's consider an example:

var gulp = require('gulp');
gulp.task('clean', function() {
    // clean up output folder
});
gulp.task('copy1', function() {
    // writes stream in the output folder
});
gulp.task('copy2', function() {
    // writes stream in the output folder
});

gulp.task('default', ['clean', 'copy1', 'copy2']);

In this example I need to run copy1 and copy2 in parallel but only after clean. How can I do this trick?

like image 734
Warlock Avatar asked Mar 28 '15 10:03

Warlock


2 Answers

var runSequence = require('run-sequence');
gulp.task('default', function(callback) {
    runSequence('clean', ['copy1', 'copy2'], callback);
});
like image 63
Raphaël Braud Avatar answered Sep 21 '22 00:09

Raphaël Braud


Be careful - there is a bug in gulp 3.x where even when using runSequence, the stream will return premature when file i/o is involved. Check out this post if you have issues:

like image 44
Will Bittner Avatar answered Sep 18 '22 00:09

Will Bittner