https://github.com/npm/ignore-walk
Nested/recursive `.gitignore`/`.npmignore` parsing and filtering.
https://github.com/npm/ignore-walk
npm-cli
Last synced: about 1 year ago
JSON representation
Nested/recursive `.gitignore`/`.npmignore` parsing and filtering.
- Host: GitHub
- URL: https://github.com/npm/ignore-walk
- Owner: npm
- License: isc
- Created: 2017-05-22T07:05:10.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2025-04-28T18:51:44.000Z (about 1 year ago)
- Last Synced: 2025-04-30T23:03:35.545Z (about 1 year ago)
- Topics: npm-cli
- Language: JavaScript
- Homepage:
- Size: 317 KB
- Stars: 62
- Watchers: 12
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# ignore-walk
Nested/recursive `.gitignore`/`.npmignore` parsing and filtering.
Walk a directory creating a list of entries, parsing any `.ignore`
files met along the way to exclude files.
## USAGE
```javascript
const walk = require('ignore-walk')
// All options are optional, defaults provided.
// this function returns a promise, but you can also pass a cb
// if you like that approach better.
walk({
path: '...', // root dir to start in. defaults to process.cwd()
ignoreFiles: [ '.gitignore' ], // list of filenames. defaults to ['.ignore']
includeEmpty: true|false, // true to include empty dirs, default false
follow: true|false // true to follow symlink dirs, default false
}, callback)
// to walk synchronously, do it this way:
const result = walk.sync({ path: '/wow/such/filepath' })
```
If you want to get at the underlying classes, they're at `walk.Walker`
and `walk.WalkerSync`.
## OPTIONS
* `path` The path to start in. Defaults to `process.cwd()`
* `ignoreFiles` Filenames to treat as ignore files. The default is
`['.ignore']`. (This is where you'd put `.gitignore` or
`.npmignore` or whatever.) If multiple ignore files are in a
directory, then rules from each are applied in the order that the
files are listed.
* `includeEmpty` Set to `true` to include empty directories, assuming
they are not excluded by any of the ignore rules. If not set, then
this follows the standard `git` behavior of not including
directories that are empty.
Note: this will cause an empty directory to be included if it
would contain an included entry, even if it would have otherwise
been excluded itself.
For example, given the rules `*` (ignore everything) and `!/a/b/c`
(re-include the entry at `/a/b/c`), the directory `/a/b` will be
included if it is empty.
* `follow` Set to `true` to treat symbolically linked directories as
directories, recursing into them. There is no handling for nested
symlinks, so `ELOOP` errors can occur in some cases when using this
option. Defaults to `false`.