Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 638
Nick Perkins Avatar asked Nov 09 '15 18:11

Nick Perkins


People also ask

What is CB () in Gulp?

To indicate to gulp that an error occurred in a task using an error-first callback, call it with an Error as the only argument. function callbackError(cb) { // `cb()` should be called by some async work. cb(new Error('kaboom')); }

Is gulp async?

This is because in Gulp (starting with version 4) all tasks are automatically asynchronous. Synchronous functions are executed one after another, and each function must wait for the previous one to complete before they start themselves.


2 Answers

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

like image 76
joe_flash Avatar answered Oct 30 '22 17:10

joe_flash


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

like image 24
harishr Avatar answered Oct 30 '22 17:10

harishr