onkami
onkami

Reputation: 9411

gulp - chaining several gulp.src-gulp.dest expressions in one task?

I have a gulp task that contains typical expressions of src-pipe-dest, similar to default example of gulp:

 gulp.src('client/templates/*.jade')
      .pipe(jade())
      .pipe(minify())
      .pipe(gulp.dest('build/minified_templates'));

and if I want some other task to start after this one, I use "return" of the abovementioned expression to indicate upstream task when the sequence is done.

However, what can I do if my task requires several such expressions, and I want gulp to continue after all of them are done? (I use run-sequence for the set of many gulp tasks).

Upvotes: 0

Views: 349

Answers (1)

Patrick Kostjens
Patrick Kostjens

Reputation: 5105

You are probably looking for Gulp's dependencies.

Suppose your tasks are named one, two, three and four. Now suppose the first three need to be done before four is being started. Furthermore, the first three are allowed to run in parallel. This would result in the following definition for task four:

gulp.task('four', ['one', 'two', 'three'], function() {
    // Your task `four` code here
});

This way, you only need to make sure the first three tasks return the correct objects so Gulp knows when they are done. When your run task four in this case, it will automatically start the first three tasks and wait for them to complete before running.

Upvotes: 1

Related Questions