gulp-foreach
Send each file in a stream down its own stream
Install
```bash $ npm install --save-dev gulp-foreach ```Usage
```js var gulp = require('gulp'); var foreach = require('gulp-foreach'); gulp.task('default', function () { return gulp.src('src/.js').pipe(foreach(function(stream, file){
return stream
.pipe(doSomethingWithEachFileIndividually())
.pipe(concat(file.name));
}))
.pipe(gulp.dest('dist'));
});
```
API
The foreach method takes one argument, a function. This function is called once for each file piped toforeach
and is passed a stream as its first argument and the file as its second argument. The stream contains only one file.
You can optionally return a stream from the foreach
function. All the streams returned from foreach
will be combined and their contents will be emited by foreach
.