Closed TrySound closed 8 years ago
By the way I was able to use null dependencies
in gulp3
gulp.task('build', env.clean ? ['clean'] : null, function (done) {done();});
I'm not sure how I feel about this. It goes against functional composition. Why not just use a named function called noop or something?
I wouldn't like to see noop in log, caz it's nothing do. Maybe some gulp.noop() which will be ignored in log?
@TrySound I've thought about this some more and I don't think this case should be supported. By "nulling" out some tasks, you will be screwing up the tasks listed by gulp --tasks
because the dependency trees are built when the gulpfile is loaded and the task listing loads the gulpfile. This is something you can still do but I don't think the average user should be doing it, as it can be confusing and I don't want to adjust the API to make it easier for them to get confused.
The recommended way for this would be to put an early return in your task and maybe use gulplog
to log a skipped message. You could make this into an interesting helper; maybe something like:
function skippable(condition, fn){
if (!condition) {
return fn;
}
function skipped(cb){
cb();
}
skipped.displayName = (fn.name || fn.displayName) + ' (skipped)';
return skipped;
}
function clean(cb){ ... }
gulp.task(skippable(env.clean, clean));
It would be cool to implement accepting null values in
gulp.series
andgulp.parallel
. My case isFor now I should pass something like
But I don't like to pass
anonymous
or named task, I just would like to skip it.