@dozerg/find-up
Version:
Find files or directories by walking up parent directories.
31 lines (30 loc) • 1.16 kB
TypeScript
export interface Options {
/**
* The directory to start from. Default to `process.cwd()`;
*/
cwd?: URL | string;
/**
* The type of paths that can match. Default to _"file"_;
*/
type?: 'file' | 'directory';
/**
* Allow symlinks to match if they point to the chosen path type. Default to _true_.
*/
allowSymlinks?: boolean;
/**
* The path to the directory to stop the search before reaching root if there were no matches.
* Default to `path.parse(cwd).root`.
*/
stopAtPath?: URL | string;
/**
* Stop the search once a number of results have been found. Default to `Number.POSITIVE_INFINITY`.
*/
stopAtLimit?: number;
}
type Matcher = (directory: string) => string | Promise<string> | undefined;
declare function findUp(name: string | readonly string[] | Matcher, options?: Options): Promise<string[]>;
declare namespace findUp {
var sync: (name: string | readonly string[] | Matcher, options?: Options) => string[];
var gen: (name: string | readonly string[] | Matcher, options?: Options) => AsyncGenerator<string, void, unknown>;
}
export default findUp;