Comparing version 0.1.4 to 0.1.5
@@ -12,5 +12,6 @@ var util = require('util'), | ||
var includes = (typeof include === 'string') ? include.split(' ') : include; | ||
var excludes = (typeof exclude === 'string') ? exclude.split(' ') : exclude; | ||
var em = new EventEmitter, | ||
includes = include.split(' '), | ||
excludes = exclude.split(' '), | ||
remaining = includes.length, | ||
@@ -17,0 +18,0 @@ results = []; |
@@ -5,3 +5,3 @@ { | ||
"description": "Wrapper around miniglob / minimatch combo to allow multiple patterns matching and include-exclude ability", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"homepage": "https://github.com/mklabs/node-fileset", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -6,17 +6,17 @@ # node-fileset | ||
[minimatch](https://github.com/isaacs/minimatch) combo both written by | ||
@isaacs. Glob now uses javascript instead of C++ bindings and make it | ||
usable in node 0.6.x and windows platforms. | ||
@isaacs. Glob now uses JavaScript instead of C++ bindings which makes it | ||
usable in Node.js 0.6.x and Windows platforms. | ||
[![Build Status](https://secure.travis-ci.org/mklabs/node-fileset.png)](http://travis-ci.org/mklabs/node-fileset) | ||
Enable multiples patterns matching, and include exlude ability. This is | ||
bascially just sugar API syntax where you can specify a list of includes | ||
and optionnal exclude patterns. It works by setting up the necessary | ||
Adds multiples patterns matching and exlude ability. This is | ||
basically just a sugar API syntax where you can specify a list of includes | ||
and optional exclude patterns. It works by setting up the necessary | ||
miniglob "fileset" and filtering out the results using minimatch. | ||
## install | ||
## Install | ||
npm install fileset | ||
## usage | ||
## Usage | ||
@@ -37,32 +37,35 @@ Can be used with callback or emitter style. | ||
* *include*: Emitted each time an include match is found. | ||
* *exclude*: Emitted each time an an exclude match is found and filtered | ||
* *exclude*: Emitted each time an exclude match is found and filtered | ||
out from the fileset. | ||
* *end*: Emitted when the matching is finished with all the matches | ||
found, optionnaly filterd by the exclude patterns. | ||
found, optionally filtered by the exclude patterns. | ||
#### callback | ||
#### Callback | ||
var fileset = require('fileset'); | ||
```js | ||
var fileset = require('fileset'); | ||
fileset('**/*.js', '**.min.js', function(err, files) { | ||
if (err) return console.error(err); | ||
fileset('**/*.js', '**.min.js', function(err, files) { | ||
if (err) return console.error(err); | ||
console.log('Files: ', files.length); | ||
console.log(files); | ||
}); | ||
console.log('Files: ', files.length); | ||
console.log(files); | ||
}); | ||
``` | ||
#### Event emitter | ||
#### event emitter | ||
```js | ||
var fileset = require('fileset'); | ||
var fileset = require('fileset'); | ||
fileset('**.coffee README.md *.json Cakefile **.js', 'node_modules/**') | ||
.on('match', console.log.bind(console, 'error')) | ||
.on('include', console.log.bind(console, 'includes')) | ||
.on('exclude', console.log.bind(console, 'excludes')) | ||
.on('end', console.log.bind(console, 'end')); | ||
``` | ||
fileset('**.coffee README.md *.json Cakefile **.js', 'node_modules/**') | ||
.on('match', console.log.bind(console, 'error')) | ||
.on('include', console.log.bind(console, 'includes')) | ||
.on('exclude', console.log.bind(console, 'excludes')) | ||
.on('end', console.log.bind(console, 'end')); | ||
fileset returns an instance of EventEmitter, with an `includes` property | ||
`fileset` returns an instance of EventEmitter, with an `includes` property | ||
which is the array of Fileset objects (inheriting from | ||
`miniglob.Miniglob`) that were used during the mathing process, shoud | ||
`miniglob.Miniglob`) that were used during the mathing process, should | ||
you want to use them individually. | ||
@@ -74,10 +77,10 @@ | ||
## tests | ||
## Tests | ||
just run `npm test` | ||
Run `npm test` | ||
## why | ||
## Why | ||
mainly as a build tool with cake files, to provide me an easy way to get | ||
a list of files by either using glob or path patterns, optionnaly | ||
Mainly for a build tool with cake files, to provide me an easy way to get | ||
a list of files by either using glob or path patterns, optionally | ||
allowing exclude patterns to filter out the results. | ||
@@ -87,2 +90,2 @@ | ||
[Glob](https://github.com/isaacs/node-glob) and | ||
[minimatch](https://github.com/isaacs/minimatch), check them out ! | ||
[minimatch](https://github.com/isaacs/minimatch). Check them out! |
@@ -30,3 +30,3 @@ | ||
assert.ok(Array.isArray(results), 'should be an array'); | ||
assert.equal(results.length, 3); | ||
assert.equal(results.length, 4); | ||
em.emit('end'); | ||
@@ -40,3 +40,3 @@ }); | ||
assert.ok(Array.isArray(results), 'should be an array'); | ||
assert.equal(results.length, 4); | ||
assert.equal(results.length, 5); | ||
@@ -46,2 +46,3 @@ assert.deepEqual(results, [ | ||
'lib/fileset.js', | ||
'tests/fixtures/an (odd) filename.js', | ||
'tests/helper.js', | ||
@@ -59,6 +60,7 @@ 'tests/test.js' | ||
assert.ok(Array.isArray(results), 'should be an array'); | ||
assert.equal(results.length, 1); | ||
assert.equal(results.length, 2); | ||
assert.deepEqual(results, [ | ||
'lib/fileset.js' | ||
'lib/fileset.js', | ||
'tests/fixtures/an (odd) filename.js', | ||
]); | ||
@@ -82,3 +84,3 @@ | ||
assert.ok(Array.isArray(results), 'should be an array'); | ||
assert.equal(results.length, 3); | ||
assert.equal(results.length, 4); | ||
em.emit('end'); | ||
@@ -93,3 +95,3 @@ }); | ||
assert.ok(Array.isArray(results), 'should be an array'); | ||
assert.equal(results.length, 4); | ||
assert.equal(results.length, 5); | ||
@@ -99,2 +101,3 @@ assert.deepEqual(results, [ | ||
'lib/fileset.js', | ||
'tests/fixtures/an (odd) filename.js', | ||
'tests/helper.js', | ||
@@ -111,5 +114,28 @@ 'tests/test.js' | ||
test('Testing patterns passed as arrays', function() { | ||
return { | ||
'Should match files passed as an array with odd filenames': function(em) { | ||
fileset(['lib/*.js', 'tests/fixtures/an (odd) filename.js'], ['node_modules/**']) | ||
.on('error', em.emit.bind(em, 'error')) | ||
.on('end', function(results) { | ||
assert.ok(Array.isArray(results), 'should be an array'); | ||
assert.equal(results.length, 2); | ||
assert.deepEqual(results, [ | ||
'lib/fileset.js', | ||
'tests/fixtures/an (odd) filename.js', | ||
]); | ||
em.emit('end'); | ||
}); | ||
} | ||
} | ||
}); | ||
test.run(); | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11692
9
200
88