in the snippet like this:
gulp.task \"coffee\", ->
gulp.src(\"src/server/**/*.coffee\")
.pipe(coffee {bare: true}).on(\"error\",gutil.log)
Gulp and Node use promises.
So you can do this:
// ... require gulp, del, etc
function cleanTask() {
return del('./dist/');
}
function bundleVendorsTask() {
return gulp.src([...])
.pipe(...)
.pipe(gulp.dest('...'));
}
function bundleAppTask() {
return gulp.src([...])
.pipe(...)
.pipe(gulp.dest('...'));
}
function tarTask() {
return gulp.src([...])
.pipe(...)
.pipe(gulp.dest('...'));
}
gulp.task('deploy', function deployTask() {
// 1. Run the clean task
cleanTask().then(function () {
// 2. Clean is complete. Now run two tasks in parallel
Promise.all([
bundleVendorsTask(),
bundleAppTask()
]).then(function () {
// 3. Two tasks are complete, now run the final task.
tarTask();
});
});
});
If you return the gulp stream, you can use the then()
method to add a callback. Alternately, you can use Node's native Promise
to create your own promises. Here I use Promise.all()
to have one callback that fires when all the promises resolve.