Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deep match with higher level siblings #44

Merged
merged 1 commit into from
Apr 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function walk(output, prefix, lexer, opts, dirname='', level=0) {
if (rgx && !rgx.test(file)) continue;
!filesOnly && isMatch && output.push(join(prefix, relpath));

await walk(output, prefix, lexer, opts, relpath, rgx && rgx.toString() !== lexer.globstar && ++level);
await walk(output, prefix, lexer, opts, relpath, rgx && rgx.toString() !== lexer.globstar && level + 1);
}
}

Expand Down
2 changes: 1 addition & 1 deletion sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function walk(output, prefix, lexer, opts, dirname='', level=0) {
if (rgx && !rgx.test(file)) continue;
!filesOnly && isMatch && output.push(join(prefix, relpath));

walk(output, prefix, lexer, opts, relpath, rgx && rgx.toString() !== lexer.globstar && ++level);
walk(output, prefix, lexer, opts, relpath, rgx && rgx.toString() !== lexer.globstar && level + 1);
}
}

Expand Down
Empty file added test/fixtures/deep/a/e
Empty file.
Empty file added test/fixtures/deep/b/c/d
Empty file.
8 changes: 8 additions & 0 deletions test/glob.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,11 @@ test('glob: options.filesOnly (without glob)', async t => {
'test/fixtures/one',
]);
});

test('glob: deep match with higher level siblings', async t => {
t.plan(1);

await isMatch(t, 'test/fixtures/deep/*/c/d', {}, [
'test/fixtures/deep/b/c/d'
]);
});