Gulp: complete a task without a destination

I am trying to do a simple task to show the file size for each file in an array of paths using the gulp-size package, for example:

 var gulp = require('gulp') var size = require('gulp-size') gulp.task('size', function() { gulp.src(bigArrayOfFilePathsFromAnotherModule) .pipe(size({ showFiles: true })) }) 

When this is done, it gets part of the path, but then the task ends before all the files are processed. It works great if I connect them to the destination, but I would prefer not to copy the files anywhere. Is there a way to transfer these files to a black hole so that the task is completed?

I tried .pipe(gulp.dest('/dev/null')) , but it mistakenly tries to execute mkdir /dev/null , which already exists.

Is there a good way to stream to nowhere?

+6
source share
1 answer

You should return your stream:

 gulp.task('size', function() { return gulp.src(bigArrayOfFilePathsFromAnotherModule) .pipe(size({ showFiles: true })); }) 

Otherwise, gulp will assume that the work performed by this task is synchronous and runs by the time the anonymous function returns.

+8
source

All Articles