Skip to content

Commit

Permalink
Handle pattern with only double star
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanduc987 committed Nov 28, 2024
1 parent 8c684ec commit 20ce766
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function processPatterns(
split[split.length - 2] = '**';
split.pop();
}
transformed.push(split.join('/'));
transformed.push(split.length ? split.join('/') : '*');
} else {
transformed.push(split.length > 1 ? split.slice(0, -1).join('/') : split.join('/'));
}
Expand Down
6 changes: 6 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ const cwd = fixture.path;

after(() => fixture.rm());

test('only double star', async () => {
const files = await glob({ patterns: ['**'], cwd });
assert.deepEqual(files.sort(), ['a/a.txt', 'a/b.txt', 'b/a.txt', 'b/b.txt']);
});


test('directory expansion', async () => {
const files = await glob({ patterns: ['a'], cwd });
assert.deepEqual(files.sort(), ['a/a.txt', 'a/b.txt']);
Expand Down

0 comments on commit 20ce766

Please sign in to comment.