0

My code works but I have a 5 second timeout. The proper way would be to wait for the sequence to end and then build the jar.

Any help??

gulp.task('build-utility', function(cb) {
  runSequence('clean', ['scripts', 'vendor', 'html', 'i18n', 'css', 'webfonts', 'images'], cb);
   setTimeout(function() {
    gulp.start('jar');
   }, 5000);
});
Tiago
  • 69
  • 1
  • 7

2 Answers2

1

You can create a new Promise and wait to finish them.

Example:

gulp.task('build-utility', function(cb) {
    await new Promise((resolve, reject) => {
         runSequence('clean', ['scripts', 'vendor', 'html', 'i18n', 'css', 'webfonts', 'images'], cb);
    });

    gulp.start('jar');
});
Guilherme Martin
  • 837
  • 1
  • 11
  • 22
0

You can do it using callback mechanism

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

gulp.task('develop', function(done) {
    runSequence('clean', 'coffee', function() {
        console.log('Run something else');
        done();
    });
});

Ref : How to run Gulp tasks sequentially one after the other

Senthil
  • 2,156
  • 1
  • 14
  • 19
  • Didn't work. It executes the console.log before finishing the other tasks – Tiago Oct 30 '19 at 12:16
  • the sequence of tasks like 'scripts','vendors' etc ensure they either return a stream or promise, or handle the callback .If the final argument is a function, it will be used as a callback after all the functions are either finished or an error has occurred.. Ref : https://www.npmjs.com/package/run-sequence – Senthil Oct 30 '19 at 12:55