简体   繁体   中英

Running a gulp task after build is complete

I want to build out a project and then have it run my 'sftp' task to upload the project when its done with gulp. My project is structured similarly as below. I have a few tasks running to 'build' the project and then want it to upload when its complete. I have the SFTP task working properly it's just the async issue.

// I want build:all to run first
gulp.task('build:all', ['one', 'two', 'three'], function(cb) {
    cb(err);
});

// I want SFTP to run after build:all is done
gulp.task('sftp', ['build:all'], function() {

    // upload some files

});

// on task build just run everything
gulp.task('build', ['sftp']);


gulp.task('default', ['build']);

You can use the cb argument when you want to do some async task:

// I want SFTP to run after build:all is done
gulp.task('sftp', ['build:all'], function(cb) {
    doSomeAsyncUpload().then(function(){
        cb()
    })
});

And build will be runned only after sftp calls cb

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM