有一个超级简单的gulp文件,我想一个接一个地按顺序运行一些基本的gulp任务。
我似乎无法在Gulp v4中运行。在使用run-sequence而不是gulp.series()
的Gulp v3中有类似的东西
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-app
和clean-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-app
和clean-tests
都返回了我认为足够的流。
尝试过使用gulp4-run-sequence,但我得到了同样的错误。
希望能够运行gulp all-tasks
,以便在clean-tests
成功完成后执行clean-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'));