Skip to content

Path.rglob() method

pathlib-ts > Path > rglob

Asynchronously performs a recursive glob in this subtree, and yields all existing files (of any kind, including directories) matching the given relative pattern.

Signature:

rglob(pattern: string, options?: fs.GlobOptions): Promise<Path[]>;

Parameter

Type

Description

pattern

string

Glob pattern to evaluate recursively.

options

fs.GlobOptions

(Optional) Options forwarded to Node’s glob implementation.

Returns:

Promise<Path[]>

Promise resolving to matching Path objects.

The UnsupportedOperation If globbing is not supported by the runtime.

Equivalent to prefixing the pattern with the recursive "**" segment and calling Path.glob(). fs.glob support.

Recursively locating markdown pages

import { Path } from "pathlib-ts";
const content = new Path("./content");
const docs = await content.rglob("**.mdx");
console.log(docs.length);