Skip to content

parse

parse(pathLike, opts?): SegmentPattern

Split a path-like glob into segments on the separator. Each segment is a glob token, verbatim — no classification. A trailing separator (which splits into an empty final segment) is normalized off, so src/api/ == src/api. Nothing else is collapsed or inferred.

ParameterTypeDescription
pathLikestringA path-like glob string, e.g. "src/api/**".
opts?{ separator?: string; }Parsing options. separator overrides the split character (default "/").
opts.separator?string-

SegmentPattern

The SegmentPattern — the segments in order, the segment core’s unit.

No inference: a pattern with no wildcards is an exact-path match (src/siteA/components matches only that path, not files beneath it); opt into a subtree explicitly with a trailing **. Only a single trailing separator is normalized off.

parse("src/api/**"); // ["src", "api", "**"]
parse("src/api/"); // ["src", "api"] — trailing separator normalized off
parse("README.md"); // ["README.md"] — no wildcards → an exact-path match