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.
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')); }
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.
An old post, but no extra node package required now. gulp.src('.')
should work just fine, as @Nick Perkins mentioned.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With