Reputation: 90101
Given:
gulp.task("watch", function()
{
// Asynchronous execution
return gulp.src("...").
doSomething1();
});
gulp.task("default", function()
{
// Synchronous execution
doSomething2();
doSomething3();
});
gulp.task("css", ["csslint"]);
I would like css
to run after default
or watch
completes but I can't declare default
or watch
as dependencies because that would trigger their execution.
How do I declare an optional dependency? (run css
after default
or watch
if they are already scheduled for execution, but don't schedule their execution).
Upvotes: 1
Views: 552
Reputation: 28141
I don't believe gulp supports the concept of optional dependencies. I believe what you need is run-sequence. It'll allow you to do this:
var sequence = require('run-sequence');
gulp.task('mySequence', sequence(
['task1', 'task2'], // ok to run these in parallel
'task3' // will not run until 1 and 2 are both completed
));
It looks like gulp v4 will address this shortcoming.
Upvotes: 1