What do I return from my Gulp task if I decide to do nothing?
Asked Answered
F

2

8

Suppose my gulp task decides to do nothing -- what should I return?

gulp.task 'maybe_transform_files', ->
    if check_something()
        gulp.src('src')
            .pipe transform_files()
            .pipe gulp.dest('target')
    else
        return something

In other situations, I might use the done() callback, but I don't think I can use it here, where I might return a stream.

Floria answered 9/11, 2015 at 18:30 Comment(0)
C
7

An old post, but no extra node package required now. gulp.src('.') should work just fine, as @Nick Perkins mentioned.

Chicoine answered 27/5, 2020 at 17:21 Comment(0)
M
4

have a look at gulp-nop

what you can do to have no-op is

var nop = require('gulp-nop');

.....

return gulp.src('.').pipe(nop());

or if you are using gulp-util you can use noop, similarly

Mcmullan answered 10/11, 2015 at 3:55 Comment(2)
How does that help? How is that different from just returning "gulp.src('.')" ?Floria
update: gulp-util is now deprecated according to https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5, so one should refrain from using itFairground

© 2022 - 2024 — McMap. All rights reserved.