finder-on-steroids
v1.0.3
Published
Recursively find and filter files and folders in a directory.
Downloads
3,171
Maintainers
Readme
finder-on-steroids
Recursively find and filter files and folders in a directory.
Installation
npm install --save finder-on-steroids
Usage
import finder from "../src";
const directory = process.argv[4] || ".";
finder(directory)
.files()
.depth(1)
.name("*.ts")
.find()
.then(
files => {
console.log("\n Found " + files.length + " TypeScript files:");
console.log(" - " + files.sort().join("\n - ") + "\n");
},
error => console.error(error)
);
API
finder(directory: string): Finder
Create a new finder object.
.files(): Finder
Restrict results to contain only files as identified by fs.Stat.isFile()
.
.directories(): Finder
Restrict results to contain only directories identified by fs.Stat.isDirectory()
.
.depth(max: number) : Finder
.depth(min: number, max: number) : Finder
Restrict results to contain only paths up to a specific depth.
.name(pattern: string|RegExp): Finder
Restrict results to contain only files and directories with base names that match the specified pattern. Takes a glob string or a RegExp.
.path(pattern: string|RegExp): Finder
Restrict results to contain only files and directories with dir names that match paths that match the specified pattern. Takes a glob string or RegExp.
.size(max: number) : Finder
.size(min: number, max: number) : Finder
Restrict results to contain only files and directories of size within the specified range.
.include(filter: string | RegExp | (path: string, stats: Stats) => boolean): Finder
Restrict results to contain only files and directories according to a custom filter function.
.exclude(filter: string | RegExp | (path: string, stats: Stats) => boolean): Finder
Restrict results to contain only files and directories according to a custom filter function.
.find(): Promise<string[]>
Start finding files.
License
The MIT License (MIT)
Copyright (c) 2014 James Newell