Samantha J T Star
Samantha J T Star

Reputation: 32828

How can I run one gulp function after another in a javascript function?

Here's what I have right now:

function make_exHtml(config) {

    gulp.src(config, { base: process.cwd() })
      .pipe(print(function (file) {
          return "Found file " + file;
      }))
      .pipe(rename({ basename: 'base' }))
      .pipe(gulp.dest('./'));

    return gulp.src(config.srcTemplates)
          .pipe(print(function (file) {
              return "Added file " + file + " to template";
          }))
       .pipe(minifyHTML({ collapseWhitespace: true }))
       .pipe(templateCache({ standalone: true, root: '/app' }))
       .pipe(gulp.dest(config.destPartials))
       .pipe(gzip(gzip_options))
       .pipe(gulp.dest(config.destPartials));
}

What I need to do is to be sure that the first gulp runs before the second. Can someone tell me how I can do this?

Upvotes: 1

Views: 238

Answers (1)

Dmitriy Nevzorov
Dmitriy Nevzorov

Reputation: 6078

You can use run-sequence. Split make_exHtml into two tasks

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

gulp.task('make_exHtml', function(callback) {
  runSequence('first_task','second_task', function(){
    make_prod('xxx');
    callback();
  });
});

Upvotes: 1

Related Questions