0.2.0 • Published 7 years ago

gulp-group-aggregate v0.2.0

Weekly downloads
174
License
MIT
Repository
github
Last release
7 years ago

gulp-group-aggregate NPM version NPM dep Build status

a group and aggregate plugin for gulp

Usage

First, install gulp-group-aggregate as a development dependency:

npm install --save-dev gulp-group-aggregate

Then, 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.

0.2.0

7 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago