From b48c2d2c31a7ddb8326fe070f822eb9794607b2c Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Fri, 20 Sep 2019 16:17:52 +0100 Subject: [PATCH] Improve directory expansion --- testing/runner.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/testing/runner.ts b/testing/runner.ts index 9c5bd386f9a6..5e90b8c999fd 100755 --- a/testing/runner.ts +++ b/testing/runner.ts @@ -11,11 +11,7 @@ import { isAbsolute, join } from "../fs/path/mod.ts"; import { RunOptions, runTests } from "./mod.ts"; const { DenoError, ErrorKind, args, cwd, exit } = Deno; -const DIR_GLOBS = ["**/?(*_)test.{js,ts}"]; - -function applyDirGlobs(root: string): string[] { - return DIR_GLOBS.map((s: string): string => `${join(root, s)}`); -} +const DIR_GLOBS = [join("**", "?(*_)test.{js,ts}")]; function showHelp(): void { console.log(`Deno test runner @@ -33,7 +29,7 @@ OPTIONS: ARGS: [MODULES...] List of test modules to run. A directory will expand to: - ${applyDirGlobs("") + ${DIR_GLOBS.map((s: string): string => `${join("", s)}`) .join(` `)} Defaults to "." when none are provided. @@ -60,8 +56,8 @@ function partition( } function expandDirectory(dir: string, options: ExpandGlobOptions): WalkInfo[] { - return applyDirGlobs(dir).flatMap((s: string): WalkInfo[] => [ - ...expandGlobSync(s, options) + return DIR_GLOBS.flatMap((s: string): WalkInfo[] => [ + ...expandGlobSync(s, { ...options, root: dir }) ]); }