I have a very basic usage of gulp-foreach that's failing so badly I imagine I must be doing something wrong; I'm just (for now) trying to print all files found in gulp.src. When doing this with gulp-foreach
only a very, very small sample of the files are ever printed—about 15 out of many hundreds. When using gulp-print things work as expected.
const gulp = require('gulp'),
foreach = require('gulp-foreach'),
gulpPrint = require('gulp-print');
gulp.src([`../../**/*.js`].concat([]))
.pipe(gulpPrint(path => {
console.log(path);
}))
.pipe(foreach((stream, file) => {
console.log(file.path);
return stream;
}))
The code with the foreach
is triggered about 15 times, interleaved with the gulpPrint
, followed by a flood of gulpPrint
statements alone. If I comment out the gulpPrint
part, foreach
prints about 15 times and then exits, and gulpPrint
alone, as expected, floods the console with every file found, as it should.
I can just use gulp-print
, but I'd like to know what I'm doing wrong with gulp-foreach
.