Skip to content

Commit

Permalink
feat(path): Align globToRegExp() with bash glob expansion (denoland/d…
Browse files Browse the repository at this point in the history
…eno#7209)

- feat: Support escaping glob characters
- feat: Support more character classes
- feat: Match characters literally on segment parse failure
- fix: Match nothing for empty globs
- fix: Contain any glob syntax to its path segment
- perf: Remove extraneous separators from generated regex
- doc: Add detailed JSDoc
- chore: Remove old copyright headers
  • Loading branch information
nayeemrmn authored and caspervonb committed Jan 31, 2021
1 parent bbb5d0f commit 30f72f0
Show file tree
Hide file tree
Showing 3 changed files with 347 additions and 220 deletions.
25 changes: 13 additions & 12 deletions fs/expand_glob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,17 @@ function comparePath(a: WalkEntry, b: WalkEntry): number {
return 0;
}

/**
* Expand the glob string from the specified `root` directory and yield each
/** Expand the glob string from the specified `root` directory and yield each
* result as a `WalkEntry` object.
*
* Examples:
* See [`globToRegExp()`](../path/glob.ts#globToRegExp) for details on supported
* syntax.
*
* for await (const file of expandGlob("**\/*.ts")) {
* console.log(file);
* }
* Example:
*
* for await (const file of expandGlob("**\/*.ts")) {
* console.log(file);
* }
*/
export async function* expandGlob(
glob: string,
Expand Down Expand Up @@ -168,14 +170,13 @@ export async function* expandGlob(
yield* currentMatches;
}

/**
* Synchronous version of `expandGlob()`.
/** Synchronous version of `expandGlob()`.
*
* Examples:
* Example:
*
* for (const file of expandGlobSync("**\/*.ts")) {
* console.log(file);
* }
* for (const file of expandGlobSync("**\/*.ts")) {
* console.log(file);
* }
*/
export function* expandGlobSync(
glob: string,
Expand Down
Loading

0 comments on commit 30f72f0

Please sign in to comment.