在 gulp版本3 中,我的help
gulp任务定义为:
gulp.task('help', function() {
var command = chalk.bold.green;
console.log(command('gulp build-task') + ': runs certain build tasks');
});
gulp.task('default', ['help']);
我执行以下操作以将其转换为 gulp版本4 :
gulp.task('help', function() {
var command = chalk.bold.green;
console.log(command('gulp build-task') + ': runs certain build tasks');
});
gulp.task('default', gulp.series('help'));
在运行gulp
时,我看到以下错误:
[01:58:01] The following tasks did not complete: default, help
[01:58:01] Did you forget to signal async completion?
我还希望先运行help
任务,然后再运行default
。在我的第4版示例中,default
首先运行。
有人可以帮我吗?谢谢!
答案 0 :(得分:0)
signal task completion有很多方法。最简单的一种-您的函数应返回promise(使用async function):
gulp.task('help', async function() {
var command = chalk.bold.green;
console.log(command('gulp build-task') + ': runs certain build tasks');
});
gulp.task('default', gulp.series('help'));
稍加清理后:
async function help() {
const command = chalk.bold.green;
console.log(command('gulp build-task') + ': runs certain build tasks');
};
gulp.task('default', gulp.series(help));