0.2.0 • Published 8 years ago
gulp-group-aggregate v0.2.0
gulp-group-aggregate

a group and aggregate plugin for gulp
Usage
First, install gulp-group-aggregate as a development dependency:
npm install --save-dev gulp-group-aggregateThen, add it to your gulpfile.js:
var path = require('path');
var groupAggregate = require('gulp-group-aggregate');
var processFiles = function (files) {...};
gulp.task('folderWrap', function(){
gulp.src(...)
.pipe(groupAggregate({
group: function (file){
// group by the directory name of each file
return path.basename(path.dirname(file.path));
},
aggregate: function (group, files){
// create a new file by processing the grouped files
return {
path: group + '.html',
contents: new Buffer(processFiles(files))
};
}
}));
.pipe(gulp.dest(...));
});API
gulp-group-aggregate is a function(options) that returns a read-write stream. The options argument should include two functions: group and aggregate.
options.group
Type: function(File) returns string
Receives a vinyl from the stream and returns a string which represents its group.
options.aggregate
Type: function(string, File[]) returns File.options
Receives a group string as returned from group calls and an array of all the files associated with it. Returns a vinyl constructor.options object. The options will be used to construct a file which will be pushed through the stream.