I no longer maintain this lib, please use other alternatives.
Find files or directories by name.
$ npm install --save find
Find all files in current directory.
var find = require('find');
find.file(__dirname, function(files) {
console.log(files.length);
})
Filter by regular expression.
find.file(/\.js$/, __dirname, function(files) {
console.log(files.length);
})
- Recursively search each sub-directories
- Asynchronously or synchronously
- Filtering by regular expression or string comparing
- Added
.use()
method
- The first
pattern
option is now optional - Will follow symbolic links
find.file(__dirname, function(files) {
//
})
find.dir(__dirname, function(dirs) {
//
})
find.eachfile(__dirname, function(file) {
//
})
find.eachdir(__dirname, function(dir) {
//
})
var files = find.fileSync(__dirname);
var dirs = find.dirSync(__dirname);
Handling errors in asynchronous interfaces
find
.file(__dirname, function(file) {
//
})
.error(function(err) {
if (err) {
//
}
})
Detect end
in find.eachfile
and find.eachdir
find
.eachfile(__dirname, function(file) {
//
})
.end(function() {
console.log('find end');
})
fs
: The internal fs object to be used.
const { fs, vol } = require('memfs');
const json = {
'./README.md': '1',
'./src/index.js': '2'
};
vol.fromJSON(json, '/app');
find
.use({ fs: fs })
.file('/app', console.log);