Skip to content

Commit

Permalink
Add documentation on how to ignore files using functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajedi32 committed Oct 18, 2015
1 parent d478481 commit 833a8e5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,24 @@ recursive('some/path', ['foo.cs', '*.html'], function (err, files) {
});
```

You can also pass functions which are called to determine whether or not to
ignore a file:

```javascript
var recursive = require('recursive-readdir');

function ignoreFunc(file, stats) {
// `file` is the absolute path to the file, and `stats` is an `fs.Stats`
// object returned from `fs.lstat()`.
return stats.isDirectory() && path.basename(file) == "test";
}

// Ignore files named 'foo.cs' and descendants of directories named test
recursive('some/path', ['foo.cs', ignoreFunc], function (err, files) {
// Files is an array of filename
console.log(files);
});
```

The ignore strings support Glob syntax via
[minimatch](https://github.com/isaacs/minimatch).

0 comments on commit 833a8e5

Please sign in to comment.