From 326ccb1095adeb9b8c86d42cc9d9d8566bba2788 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Thu, 1 Oct 2020 10:37:03 +0100 Subject: feat(std/path): Align globToRegExp() with bash glob expansion (#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 --- std/fs/expand_glob.ts | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'std/fs') diff --git a/std/fs/expand_glob.ts b/std/fs/expand_glob.ts index 72907e157..db60b2465 100644 --- a/std/fs/expand_glob.ts +++ b/std/fs/expand_glob.ts @@ -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, @@ -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, -- cgit v1.2.3