-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gulp 4: How do I prevent from duplicated dependent task execution? #1392
Comments
In my understanding, Gulp 4 is encouraging named logic functions. You call said functions from Here's a quick example based on your sample code: var gulp = require('gulp')
function task0(done) {
console.log(0)
done()
}
function task1(done) {
setTimeout(function() {
console.log(1)
done()
}, 1000)
}
function task2(done) {
setTimeout(function() {
console.log(2)
done()
}, 2000)
}
function def(done) {
console.log('default')
done()
}
gulp.task('0', task0)
gulp.task('1', gulp.series(task0, task1))
gulp.task('2', gulp.series(task0, task2))
gulp.task('default', gulp.series(
task0,
gulp.parallel(task1, task2),
def
))
EDIT just noticed your |
@codekirei is correct about this. Gulp 3 required you to register every function you wanted to access and then you used strings to represent those tasks. In gulp 4, we wanted to move towards a functional, composition-based architecture so you can create named or anonymous functions and reuse them in the You could also use a module I created called async-once if you want to keep the gulpfile in the original post, but I don't recommend it because it doesn't work with returning streams, etc. |
Thank you @codekirei and @phated. |
Probably not in the sense that you're thinking of. Gulp 3 used orchestrator to compose tasks, while Gulp 4 has switched to undertaker. Undertaker does not have orchestrator's concept of dependencies baked into its API. In Gulp 4, dependency is achieved through standard JS control flow techniques (i.e. in your logic functions) or undertaker's |
I think I got it. Thank you @codekirei ! |
Great! You're welcome 😁 |
It brings us a task hell. Additionally to our usual bunch of tasks we have to make a task for every combination of the tasks. |
You are obviously missing something fundamental. Much of this will be addressed in the documentation updates we are working on. |
I have a configuration file of gulp 3.
The execution result is:
After migrating it to gulp 4 version.
The task 0 has been executed twice.
I need gulp.series to keep dependencies in sequence, but I can't find any information to prevent duplicated execution.
The text was updated successfully, but these errors were encountered: