Felice Pollano
Felice Pollano

Reputation: 33272

Gulp-hg task seems to finish before actually complete

I've got a task in gulp, using gulp-hg, as follow:

gulp.task('init',['clean'],function(){
    return hg.clone('https://myrepo','./deploy',{args:'--insecure'},function(error,stout){
        util.log(error);
    });
});

apparently gulp execute another task depending on 'init', before the command finish. Is something wrong in the way I'm using the callback?

Upvotes: 0

Views: 52

Answers (1)

dahlbyk
dahlbyk

Reputation: 77620

You need to follow one of the async task patterns:

  1. Accept a callback
  2. Return a stream
  3. Return a promise

In your example, a callback might look like this:

gulp.task('init',['clean'],function(cb){
    hg.clone('https://myrepo','./deploy',{args:'--insecure'},function(error,stout){
        util.log(error);
        cb(error);
    });
});

Upvotes: 1

Related Questions