3.0.0 • Published 9 months ago

simple-recursive-search v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

simple-recursive-search

NPM version build status Test coverage npm download

Async function that retrieves file and directory paths.

This is still an experimental version.

This retrieves the relative path (not just the filenames.), so it's simple to:

  • rename,
  • move
  • or change these files.

Currently it will descend up to the last directory in a tree. A safety limit depth may be added soon.

Installation

$ npm i simple-recursive-search

Usage

import { search: recursiveSearch } from "simple-recursive-search";

recursiveSearch(".",{
  excludeDirs:(dirname) => /node_modules/.test(dirname),
  excludeFiles:(filename) => filename.endsWith(".jpg"),
  wantFiles:true,// default, dont need to pass
  wantDirectories:false//default, dont need to pass
  dotFiles:false//default, dont need to pass
}).then((matches) => {
  console.log(matches);
});

Or using await

import { search: recursiveSearch } from "simple-recursive-search";
async function run(){
const listOfFilesMatched = await recursiveSearch(".",{
  excludeDirs:(dirname) => /node_modules/.test(dirname)
})}
console.log(listOfFilesMatched)

License

MIT