deglob
Take a list of glob patterns and return an array of file locations, respecting `.gitignore` and allowing for ignore patterns via `package.json`.
Last updated 2 years ago by feross .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install deglob 
SYNC missed versions from official npm registry.

deglob travis npm downloads javascript style guide

Take a list of glob patterns and return an array of file locations, respecting .gitignore and allowing for ignore patterns via package.json.

Giant swaths of this code were extracted from standard. It seems useful outside of that tool, so I've attempted to extract it! :)

Install

npm install --save deglob

Usage

var deglob = require('deglob')

deglob(['**/*.js'], function(err, files) {
  files.forEach(function(file) {
    console.log('found file ' + file)
  })
})

// pass in some options to customize!

var path = require('path')
var opts = {
  cwd: path.join(__dirname, 'someDir'),
  useGitIgnore: false,
  usePackageJson: false
}

deglob(['**/*.js'], opts, function(err, files) {
  files.forEach(function(file) {
    console.log('found file ' + file)
  })
})

Ignoring files in package.json

deglob will look for a package.json file by default and use any ignore patterns defined.

To define patterns in package.json add somthing like this:

"config": {
  "ignore": ['**/*.bad']
}

If you do not fancy the config key, provide a different one using the configKey option.

Options

Option Default Description
useGitIgnore true Turn on/off allowing ignore patterns via .gitignore
usePackageJson true Turn on/off allowing ignore patterns via package.json config.
configKey 'config' This is the parent key in package.json to look for the ignore attribute.
gitIgnoreFile '.gitignore' Name of the .gitignore file look for (probably best to leave it default)
ignore [] List of additional ignore patterns to use
cwd process.cwd() This is the working directory to start the deglobbing

Contributing

Contributions welcome! Please read the contributing guidelines first.

License

ISC

Current Tags

  • 4.0.1                                ...           latest (a year ago)

13 Versions

  • 4.0.1                                ...           a year ago
  • 4.0.0                                ...           a year ago
  • 3.1.0                                ...           2 years ago
  • 3.0.0                                ...           2 years ago
  • 2.1.1                                ...           2 years ago
  • 2.1.0                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.1.2                                ...           4 years ago
  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago

Copyright 2014 - 2016 © taobao.org |