Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Wrapper around miniglob / minimatch combo to allow multiple patterns matching and include-exclude ability
JavaScript
branch: dev

This branch is 17 commits behind master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
documentation
lib
src
tests
.travis.yml
Cakefile
README.md
package.json

README.md

node-fileset

Expose a basic wrapper around node-glob by isaacs and findit by substack. Enable multiple pattern matching, and include exlude ability.

install

npm install fileset

usage

fileset

Can be used with callback or emitter style.

  • include: list of glob patterns foo/**/*.js *.md src/lib/**/*
  • exclude: optional list of glob patterns to filter include results foo/**/*.js *.md
  • callback: optional function that gets called with an error if something wrong happend, otherwise null with an array of results

The callback is optional since the fileset method return an instance of EventEmitter which emit different events you might use:

  • match: triggered on findit.file and each glob returned by node-glob, triggerd multiple times
  • includes: array of includes files, triggered once
  • excludes: array of exclude files, triggered once
  • end: array of include files, filter by exluded files, triggered once

callback

var fileset = require('fileset');

fileset('**/*.js', '**.min.js', function(err, files) {
  if (err) return console.error(err);

  console.log('Files: ', files.length);
  console.log(files);
});

event emitter

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'));

Check out the tests for more examples.

tests

just run npm test (make sure to install devDependencies too)

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 allowing exclude patterns to filter out the results.

All the magic is happening in node-glob and findity, check them out !

Something went wrong with that request. Please try again.