find

Find files or directories by name

#find

Find files or directories by name.

$ npm install 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
  • 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);
find
  .file(__dirname, function(file) {
    //   
  })
  .error(function(err) {
    if (err) {
      // 
    }
  })
find
  .eachfile(__dirname, function(file) {
    // 
  })
  .end(function() {
    console.log('find end'); 
  }) 

(MIT Licensed)