# Dependent tasks
The main pain point I had migrating it was dependent tasks started before the completion of their dependencies. This was especially painful with clean tasks and made my first attempts to fail with:
Both tasks actually ran concurrently and the clean task failed to delete the root folder since the apidoc one already added back files in the directory. The solution is pretty simple: return the processed stream for gulp to consider the task as asynchronous and wait for its actual completion before starting dependent ones.
I think one must always report asynchronous tasks as being asynchronous even though there is no dependent task to be run afer, because otherwise gulp reports the task as being finished even though it is not. For example with
the command line displays the error after telling it completed in a few microseconds
By simply returning the stream
gulp displays the error at the expected place and reports reasonnable time
The issue actually boils down to documentation, most gulp plugins show of task examples in their README without returning the stream. So please if you write a gulp plugin mark all your asynchronous examples as being asynchronous so that users can copy/paste them. It is generally only about adding a
return statement. And please if you spot a plugin with invalid documentation open a pull request.
Apart from that, as many already reported it makes the build faster, though gulp is not the only one to praise here because two tasks used to each take longer than the whole build does now. Even if gulp may be faster by being parallel by default, plugins have also improved a lot.
I really like the shape of the resulting
gulpfile.js, I find it easier to visually group related tasks and it is a bit shorter. When multiple tasks refer to the same set of files, I have been tempted to create a variable to respect DRY but it made the file look awkward so I made an exception to the rule here.