orionsoft-react-scripts
Version:
Orionsoft Configuration and scripts for Create React App.
77 lines (56 loc) • 2.29 kB
Markdown
//img.shields.io/npm/v/deglob.svg?style=flat-square
[ ]: https://www.npmjs.com/package/deglob
[ ]: https://img.shields.io/travis/flet/deglob.svg?style=flat-square
[ ]: https://travis-ci.org/flet/deglob
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](https://github.com/feross/standard). It seems useful outside of that tool, so I've attempted to extract it! :)
```
npm install --save deglob
```
```js
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)
})
})
```
`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:
```js
"config": {
"ignore": ['**/*.bad']
}
```
If you do not fancy the `config` key, provide a different one using the `configKey` option.
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](CONTRIBUTING.md) first.
## License
[ISC](LICENSE.md)
[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[ ]: https: