in the snippet like this:
gulp.task "coffee", -> gulp.src("src/server/**/*.coffee") .pipe(coffee {bare: true}).on("error",gutil.log) .pipe(gulp.dest "bin") gulp.task "clean",-> gulp.src("bin", {read:false}) .pipe clean force:true gulp.task 'develop',['clean','coffee'], -> console.log "run something else"
In develop
task I want to run clean
and after it's done, run coffee
and when that's done, run something else. But I can't figure that out. This piece doesn't work. Please advise.
To indicate to gulp that an error occurred in a task using an error-first callback, call it with an Error as the only argument. However, you'll often pass this callback to another API instead of calling it yourself.
In addition to making sure you have gulp globally installed, make sure your gulp file is named *gulpfile. js* and that is in the same directory as where you are running gulp . Then simply run gulp task1 .
Gulp is a task runner that uses Node. js as a platform. It purely uses the JavaScript code and helps to run front-end tasks and large-scale web applications. Gulp builds system automated tasks like CSS and HTML minification, concatenating library files, and compiling the SASS files.
There are 5 types of streams are available in Gulp.
By default, gulp runs tasks simultaneously, unless they have explicit dependencies. This isn't very useful for tasks like clean
, where you don't want to depend, but you need them to run before everything else.
I wrote the run-sequence
plugin specifically to fix this issue with gulp. After you install it, use it like this:
var runSequence = require('run-sequence'); gulp.task('develop', function(done) { runSequence('clean', 'coffee', function() { console.log('Run something else'); done(); }); });
You can read the full instructions on the package README — it also supports running some sets of tasks simultaneously.
Please note, this will be (effectively) fixed in the next major release of gulp, as they are completely eliminating the automatic dependency ordering, and providing tools similar to run-sequence
to allow you to manually specify run order how you want.
However, that is a major breaking change, so there's no reason to wait when you can use run-sequence
today.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With