Skip to content

Commit 833a8e5

Browse files
committed
Add documentation on how to ignore files using functions
1 parent d478481 commit 833a8e5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,24 @@ recursive('some/path', ['foo.cs', '*.html'], function (err, files) {
3838
});
3939
```
4040

41+
You can also pass functions which are called to determine whether or not to
42+
ignore a file:
43+
44+
```javascript
45+
var recursive = require('recursive-readdir');
46+
47+
function ignoreFunc(file, stats) {
48+
// `file` is the absolute path to the file, and `stats` is an `fs.Stats`
49+
// object returned from `fs.lstat()`.
50+
return stats.isDirectory() && path.basename(file) == "test";
51+
}
52+
53+
// Ignore files named 'foo.cs' and descendants of directories named test
54+
recursive('some/path', ['foo.cs', ignoreFunc], function (err, files) {
55+
// Files is an array of filename
56+
console.log(files);
57+
});
58+
```
59+
4160
The ignore strings support Glob syntax via
4261
[minimatch](https://github.com/isaacs/minimatch).

0 commit comments

Comments
 (0)