glob-fs 
node.js file globber.
TODO
Install
Install with npm
$ npm i glob-fs --save
Usage
var glob = require('glob-fs');
API
Asynchronously glob files or directories that match the given pattern
.
Params
pattern
{String}: Glob pattern
options
{Object}
cb
{Function}: Callback
Example
var glob = require('glob-fs')({ gitignore: true });
glob.readdir('*.js', function (err, files) {
});
Synchronously glob files or directories that match the given pattern
.
Params
pattern
{String}: Glob pattern
options
{Object}
returns
{Array}: Returns an array of files.
Example
var glob = require('glob-fs')({ gitignore: true });
var files = glob.readdirSync('*.js');
Stream files or directories that match the given glob pattern
.
Params
pattern
{String}: Glob pattern
options
{Object}
returns
{Stream}
Example
var glob = require('glob-fs')({ gitignore: true });
glob.readdirStream('*.js')
.on('data', function (file) {
console.log(file.path);
})
.on('error', console.error)
.on('end', function () {
console.log('end');
});
Optionally create an instance of Glob
with the given options
.
Params
Example
var Glob = require('glob-fs').Glob;
var glob = new Glob();
Thin wrapper around .use()
for easily excluding files or directories that match the given pattern
.
Params
pattern
{String}
options
{Object}
Example
var gitignore = require('glob-fs-gitignore');
var dotfiles = require('glob-fs-dotfiles');
var glob = require('glob-fs')({ foo: true })
.exclude(/\.foo$/)
.exclude('*.bar')
.exclude('*.baz');
var files = glob.readdirSync('**');
Add a middleware to be called in the order defined.
Params
fn
{Function}
returns
{Object}: Returns the Glob
instance, for chaining.
Example
var gitignore = require('glob-fs-gitignore');
var dotfiles = require('glob-fs-dotfiles');
var glob = require('glob-fs')({ foo: true })
.use(gitignore())
.use(dotfiles());
var files = glob.readdirSync('*.js');
Related projects
- braces: Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces… more
- fill-range: Fill in a range of numbers or letters, optionally passing an increment or multiplier to… more
- is-glob: Returns
true
if the given string looks like a glob pattern.
- micromatch: Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just… more
Running tests
Install dev dependencies:
$ npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Middleware conventions
- Naming: any middleware published to npm should be prefixed with
glob-fs-
, as in: glob-fs-dotfiles
.
- Keywords: please add
glob-fs
to the keywords array in package.json
- Options: all middleware should return a function that takes an
options
object, as in the below Middleware Example
- Return
file
: all middleware should return the file
object after processing.
Middleware example
All middleware runs synchronously in the order in which it's defined by the user.
function tests(options) {
return function(file) {
if (/^test\//.test(file.dirname)) {
file.exclude = true;
}
return file;
};
}
var glob = glob({ gitignore: true })
.use(tests())
glob.readdirStream('**/*')
.on('data', function (file) {
console.log(file.path);
})
Author
Jon Schlinkert
License
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
This file was generated by verb-cli on July 07, 2015.