Gulp tasks from other Gulp tasks?

I have a Gulp build task that consists of other build tasks like this:

gulp.task('build', ['build-html', 'build-css', 'build-js', 'build-images']);

      

What I hate is that the task build

doesn't start until the dependencies are complete:

Starting 'build-html'...
Finished 'build-html' after 1 s
Starting 'build-css'...
Finished 'build-css' after 1 s
Starting 'build-js'...
Finished 'build-js' after 1 s
Starting 'build-images'...
Finished 'build-images' after 1 s
Starting 'build'...
Finished 'build' after 1 ms

      

Now it is obvious that build

it shouldn't run at all until the dependencies are complete, so it works as expected. But this causes the console to say it build

only takes 1ms, when in fact it should say it took 4 seconds since all of its dependencies were taking so long. It would be nice if it looked something like this:

Starting 'build'...
Starting 'build-html'...
Finished 'build-html' after 1 s
Starting 'build-css'...
Finished 'build-css' after 1 s
Starting 'build-js'...
Finished 'build-js' after 1 s
Starting 'build-images'...
Finished 'build-images' after 1 s
Finished 'build' after 4 s

      

Note that build

- this is the first thing that "starts", then all dependencies are started, then exits build

.

So what I'm wondering is, instead of using task dependencies, can I just call each task on one of the tasks build

? If so, what command do I use to do this?

It is a bad idea? Is there a better solution to this problem?

+3


source to share


1 answer


I think you could use the runSequence plugin to do what you want.

Since the sole purpose of your task build

is to run all tasks in build-*

no particular order, it might look like this:



var rs = require('run-sequence');

gulp.task('build', function (cb) {
  rs(['build-css', 'build-html', 'build-js', 'build-images'], cb);
});

      

+1


source







All Articles