Skip to content

Path.globSync() method

pathlib-ts > Path > globSync

Performs a blocking glob search relative to this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.

Signature:

globSync(pattern: string, options?: fs.GlobOptions): Path[];

Parameter

Type

Description

pattern

string

Glob pattern interpreted relative to this path.

options

fs.GlobOptions

(Optional) Options forwarded to Node’s fs.globSync.

Returns:

Path[]

Matching paths as Path objects.

The UnsupportedOperation If fs.globSync is unavailable.

Requires runtime support for fs.globSync; otherwise UnsupportedOperation is thrown.

Gathering TypeScript sources synchronously

import { Path } from "pathlib-ts";
const repo = new Path("./src");
const matches = repo.globSync("**.ts");
console.log(matches.length);