1.0.1 • Published 8 years ago

gulp-subset v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

gulp-subset

Process a subset of files in a gulp pipeline.

Install

> npm install gulp-subset

Usage

gulp-subset uses a pattern to select a subset of files to process. Files that match the pattern are passed to the processing step while the remaining files just fall through to the next step.

var subset = require('gulp-subset');

gulp.src(['*.css','*.less'])
	.pipe(subset(/less$/, less()))  // Pipe .less files through less()
	.pipe(cssmin())
	...

The pattern can be a string, regex or custom function. Passing an extra truthy value will invert the match:

var subset = require('gulp-subset');

gulp.src(['*.css','*.less'])
	.pipe(subset(/css$/, less(), true))  // Pipe non .css files through less()
	.pipe(cssmin())
	...

API

subset(pattern, stream [,invert])

pattern : string | regex | function

The pattern is either a string, regex or function. If it is a function, it is passed a vinyl and must return true if the file is to be processed, false otherwise.

Passing a string pattern is a convience for the following matching function:

function (vinyl) { 
	return (vinyl.relative.indexOf(pattern)>=0)
}

Passing a regex pattern is a convience the following matching function:

function (vinyl) {
	return (vinyl.relative.match(pattern))
}

stream

This is any operation that you would normally pass to the pipe() function.

invert

Passing a truthy value will invert the matching subset.

Test

> npm test