Gulp is build automation tool which runs on top of Node. In my current project I had to execute set of tasks in a predefined order, in which some of the tasks can be run in parallel to improve the efficiency.
By default Gulp runs all the tasks at the same time, so after googling I saw this official article. In this approach every task will takes a callback function so that Gulp knows when that task is completed. Then other task add this as a dependency
E.g. from the official article
var gulp = require('gulp');
two is depends on task
one, so Gulp ensures that task
one is completed before running task
two.One drawback with this approach is tasks are tightly coupled to each other which reduces the flexibility if you want to change the order.
So I came across a plugin called run-sequence, this plugin allows you to order the tasks much easy. We can re-write the first example like this
var gulp = require('gulp'),
Make sure each of the tasks returns a
Running tasks in parallel
run-sequence can do much more, like running in parallel
The above one ensures that
task-2 will be running in series, after that
task-5 will run in parallel, then
task-8 are run in parallel as well.
Main advantage I see when compared to official documentation is - tasks are independent and orchestration is done by someone else.