0

I've got the following tasks that are being ran by Gulp.

  1. script-a
  2. script-b
  3. script-c

script-a is unrelated (relatively speaking) to tasks b and c, and takes around 5 seconds to run.

script-b and script-c are related so have to be ran in serial, and take around a second each to run.

Therefore, I want to be able to run a in parallel with b and c - while maintaining the latter two in serial.

I'm currently using runSequence to run them all in series;

gulp.task('script', function(callback) {
  return runSequence(
    'script-a',
    'script-b',
    'script-c',
    callback
  )
});

I can get script-a to run in parallel with one of the other tasks like so;

gulp.task('script', function(callback) {
  return runSequence(
    ['script-a', 'script-b'],
    'script-c',
    callback
  )
});

But that seems to be only half solving the problem. Seems like the answer should be obvious?

Tom
  • 4,257
  • 6
  • 33
  • 49

1 Answers1

0

You can try grouping script-b and script-c in another task and then run parallel in the task script. Something like this:

// script-b and script-c run in serial
gulp.task('scriptsBC', function(callback){
  return runSequence(
    'script-b',
    'script-c',
    callback
  )
})

// script-a and scriptBC run in paralell
gulp.task('script', function(callback) {
  return runSequence(
    ['script-a','scriptsBC'],
    callback
  )
});
  • It seems like overkill to create _another_ task to achieve what I'm after, but you might be right and it might be the only way to do it. Which is a shame! – Tom Mar 08 '17 at 09:25
  • Yea. Looks like not the better solution, but effective. – Santiago Barchetta Mar 08 '17 at 12:51
  • You can explore the version 4 of Gulp which already have two methods in it's API called [gulp.serial and gulp.paralell](https://fettblog.eu/gulp-4-parallel-and-series/) . But Gulp 4 it's not already finished, it's [just a tree in the gulp repository](https://github.com/gulpjs/gulp/tree/4.0) – Santiago Barchetta Mar 08 '17 at 12:52
  • Yes I'd looked through those changes - however I was wanting to stick to the stable version of Gulp - even if it means altering my tasks when 4 is finally released. – Tom Mar 08 '17 at 12:53