-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Gulp 4: gulp.task('default', 'build') should be same as gulp.task('default', gulp.series('build')) #1091
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
Comments
Yeah, ran into this myself. Would be nice, but it's not deal breaking IMO. |
I agree that your suggested functionality would be nice. You could get around this by making build a function: gulp.task('defualt', build);
function build() {
return gulp.src(...)
...
} This has other benefits too, like you can add a description to your build task function build() { ... }
build.description = 'this does this and that to build'; |
Sorry, we aren'y supporting this because the recommended usage pattern for gulp 4 is to use functions and be explicit in what your code is doing. You should not be using strings whenever possible, instead using named functions or setting |
But |
i agree. there’s nothing saying more clearly “'default' is an alias of 'build'” than this. both 'parallel' and 'series' are less explicit: “a series consisting of one task” and “parallel execution of one task” are simply more complicated ways of saying “one task” |
I agree, it is unclear. This annoys me about my own gulpfiles. I think this should work |
+1 ; I also tried to pass a string as it seems the most natural way to upgrade from v3 |
The first goal of gulp 4 is to promote good patterns through its APIs. We've done things like keep string task naming around for an easier upgrade path but you should be switching your gulpfiles to use named functions instead of string references everywhere. |
then why do you advertize to do i thought gulp 4 was about:
in your examples, this seems cleanest gulp.task('build', gulp.series(
clean,
gulp.parallel(scripts, images),
))
gulp.task(clean)
gulp.task(watch)
gulp.task('default', 'build') and also most consistent: strings (representing named tasks) and functions can then have the same roles:
|
another alternative would be to disallow all this and just do: let build = gulp.series(clean, gulp.parallel(scripts, images))
let default = build
gulp.task(build)
gulp.task(clean)
gulp.task(watch)
gulp.task(default) |
I have to +1 on this one, I've been using Gulp4 for a long time now, and I love it, but I was stunned when I ran into this error. If both of these work: //1
gulp.task('default', release);
//2
gulp.task('stuff', gulp.series('release', 'blah')); You'd logically expect both of these to work as well: //3
gulp.task('default', 'release');
//4
gulp.task('stuff', gulp.series(release, blah)); Instead, only the latter works and the one syntax standing out and throwing an error is number three. If you don't want people to use named tasks like this, then in my opinion they shouldn't be supported in |
I don't see a reason for not making it backwards compatible with old syntax of ['string','string','string'] which will default to parallel, and maybe put a warning here that you shouldnt really use that. Otherwise it just breaks your gulpfile. |
as it is now, i just ignore instead i use |
Loving the new
gulp.series()
andgulp.parallel()
flow, but I feel it shouldn't be necessary to type:When the following would communicate the intent even more clearly, and is less code:
The latter currently fails with
AssertionError: Task function must be specified
.See also #771.
The text was updated successfully, but these errors were encountered: