1

I've specified some Gulp tasks in a gulpSequence like this:

gulp.task('default', function(done){
    gulpSequence(
        'private:clean',
        'private:copy-app-package-file',
        'private:copy-app-main-file',
        'private:copy-libs',
        'private:copy-app-files',
        'private:copy-css-files',
        'private:build-html',
        'private:package-app',
        done);
});

I thought that they should run one after another. The build-html tasks needs the libs, app-files and css-files, because they get included within one html file.

But if I run the default task, the build-html task is missing some files. For example the task can only inject 10 files in the html file but there are 16 files.

Is there another way to specify dependent tasks. I thought the gulpSequence will handle this.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Fabian Deitelhoff
  • 712
  • 1
  • 7
  • 23
  • there is another way to put the task A as a dependency for task B, you can do it that way, but task composition will be tricky. – e-nouri Jul 29 '16 at 08:42
  • All of your tasks must correctly signal async completion. See [this answer](http://stackoverflow.com/a/36899424/5892036) (it's for gulp 4, but most of it applies to gulp 3 as well). – Sven Schoenung Jul 29 '16 at 09:16

2 Answers2

1

You're on the right lines, but the npm package you are trying to use is depreciated. Might be worth considering checking out run-sequence (https://www.npmjs.com/package/run-sequence) which waits for a previous task to complete before starting.

So in your instance, this would become

gulp.task('default', function( cb ) { $.runSequence( 'private:clean', 'private:copy-app-package-file', 'private:copy-app-main-file', 'private:copy-libs', 'private:copy-app-files', 'private:copy-css-files', 'private:build-html', 'private:package-app', cb ) });

petehotchkiss
  • 370
  • 1
  • 7
0

You specified that all tasks should run in sequence with no parallelism at all. A new task starts as soon as a former task shows completion.

Probably you have some issues in a task before the build-html task. Do they handle the completion (done() callback) correctly? In most cases I saw there was some async action triggered and the callback was called before the async task finished. So the sequence continues before the task is really over...

Andreas Jägle
  • 11,632
  • 3
  • 31
  • 31