gpt4 book ai didi

gulp - 如何在 gulp 4 中使用 gulp.series?

转载 作者:行者123 更新时间:2023-12-03 08:55:20 28 4
gpt4 key购买 nike

有一个 super 简单的 gulp 文件,我想在其中依次运行一些基本的 gulp 任务。

我似乎无法在 Gulp v4 中运行它。使用 run-sequence 在 Gulp v3 中有类似的东西而不是gulp.series()

const gulp = require("gulp");
const clean = require('gulp-clean');

gulp.task('clean-app', async () => {
return (gulp.src('./dist/app', {read: true, allowEmpty: true})
.pipe(clean()));
});


gulp.task('clean-tests', async () => {
return ( gulp.src('./dist/tests', {read: true, allowEmpty: true})
.pipe(clean()));
});

gulp.task('all-tasks', gulp.series('clean-app', 'clean-tests'));

各个 gulp 任务 clean-appclean-tests单独运行良好。

但是,当我使用gulp all-tasks时我收到以下错误

gulp all-tasks
[17:50:51] Using gulpfile ~\IdeaProjects\my-app\gulpfile.js
[17:50:51] Starting 'all-tasks'...
[17:50:51] Starting 'clean-app'...
[17:50:51] Finished 'clean-app' after 10 ms
[17:50:51] The following tasks did not complete: all-tasks
[17:50:51] Did you forget to signal async completion?

两者clean-appclean-tests我认为返回流就足够了。

已尝试使用 gulp4-run-sequence但我得到同样的错误。

希望能够运行gulp all-tasks这样clean-testsclean-app 之后执行已成功完成。

最佳答案

根据官方文档here尝试在您的任务中运行 cb() 这样的

const gulp = require("gulp");
const clean = require('gulp-clean');

gulp.task('clean-app', (cb) => {
gulp.src('./dist/app', {read: true, allowEmpty: true}).pipe(clean());
cb();
});

gulp.task('clean-tests', (cb) => {
gulp.src('./dist/tests', {read: true, allowEmpty: true}).pipe(clean());
cb();
});

gulp.task('all-tasks', gulp.series('clean-app', 'clean-tests'));

关于gulp - 如何在 gulp 4 中使用 gulp.series?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55907957/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com