Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodejs module to find files?

I search a module to find files in nodejs.

I would like something like:

var finder = require('finder');
var path = finder.find('/path/to/*.js');

Then path is an array with for example:

/path/to/file.js
/path/to/sub/file.js
...
like image 590
Charles Avatar asked Jul 01 '12 14:07

Charles


3 Answers

In addition to @pksunkara answer:

  • https://github.com/isaacs/node-glob
like image 199
TheHippo Avatar answered Nov 17 '22 12:11

TheHippo


  • https://github.com/zzak/gsub
  • https://github.com/dvv/meta-fs
like image 28
Pavan Kumar Sunkara Avatar answered Nov 17 '22 12:11

Pavan Kumar Sunkara


For simple searches supporting callbacks you can use: https://github.com/yuanchuan/find

Alternatively, you can use filehound which supports async (callbacks, promises) and sync calls. In addition, you can specify multiple search criteria like file extension, size etc

Example:

const Filehound = require('filehound');

const files = Filehound.create()
   .ext('js')
   .findSync();

console.log(files) // json files

Repo: https://github.com/nspragg/filehound

API docs: https://nspragg.github.io/filehound/

like image 1
nickool Avatar answered Nov 17 '22 10:11

nickool