All we need to do is to pass a callback function to the task definition function as follows:
gulp.task("sync", function (cb) { // We used setTimeout here to illustrate an async operation setTimeout(function () { console.log("Hello Gulp!"); cb(); // note the cb usage here }, 1000); });