Skip to content

Commit

Permalink
fs/walk.ts: Don't traverse directories matching a skip pattern
Browse files Browse the repository at this point in the history
In other words, support path prefixes when specifying excludes. This
aligns with the file matchers of the test runner and prettier. It's less
redundant since this cannot be achieved efficiently on the client-end.
  • Loading branch information
nayeemrmn committed Sep 29, 2019
1 parent 17adf62 commit de35f8f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 2 additions & 6 deletions fs/glob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ export async function* expandGlob(
const globOptions: GlobOptions = { extended, globstar, strict };
yield* walk(root, {
match: [globToRegExp(absGlob, globOptions)],
skip: absExclude.map(
(s: string): RegExp => globToRegExp(s, { ...globOptions, flags: "g" })
),
skip: absExclude.map((s: string): RegExp => globToRegExp(s, globOptions)),
includeDirs
});
}
Expand All @@ -136,9 +134,7 @@ export function* expandGlobSync(
const globOptions: GlobOptions = { extended, globstar, strict };
yield* walkSync(root, {
match: [globToRegExp(absGlob, globOptions)],
skip: absExclude.map(
(s: string): RegExp => globToRegExp(s, { ...globOptions, flags: "g" })
),
skip: absExclude.map((s: string): RegExp => globToRegExp(s, globOptions)),
includeDirs
});
}
2 changes: 2 additions & 0 deletions fs/walk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export async function* walk(
if (options.includeDirs && include(root, options)) {
const rootInfo = await stat(root);
yield { filename: root, info: rootInfo };
} else if (patternTest(options.skip || [], root)) {
return;
}
let ls: FileInfo[] = [];
try {
Expand Down

0 comments on commit de35f8f

Please sign in to comment.