Agzam Agzam - 1 year ago 116
Node.js Question

How to run Gulp tasks sequentially one after the other

in the snippet like this:

gulp.task "coffee", ->
.pipe(coffee {bare: true}).on("error",gutil.log)
.pipe(gulp.dest "bin")

gulp.task "clean",->
gulp.src("bin", {read:false})
.pipe clean

gulp.task 'develop',['clean','coffee'], ->
console.log "run something else"

task I want to run
and after it's done, run
and when that's done, run something else. But I can't figure that out. This piece doesn't work. Please advise.

Answer Source

The only good solution to this problem can be found in the gulp documentation which can be found here

var gulp = require('gulp');

// takes in a callback so the engine knows when it'll be done
gulp.task('one', function(cb) {
  // do stuff -- async or otherwise
  cb(err); // if err is not null and not undefined, the orchestration will stop, and 'two' will not run

// identifies a dependent task must be complete before this one begins
gulp.task('two', ['one'], function() {
  // task 'one' is done now

gulp.task('default', ['one', 'two']);
// alternatively: gulp.task('default', ['two']);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download