Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,21 @@ test('should map the project paths correctly', async ({ fs }) => {
{ path: join('apps/deep/deeper/f'), name: undefined },
])
})

test('should match deep packages with a globstar expression and a leading ./', async ({ fs }) => {
const cwd = mockFileSystem(
{
'package.json': '{}',
'apps/other/hello.txt': '',
'apps/deep/a/package.json': '{}',
'apps/deep/b/package.json': JSON.stringify({ name: 'b' }),
'apps/deep/c/package.json': JSON.stringify({ name: 'c' }),
'apps/deep/d/no-package': '{}',
},
'test',
)
expect(await getWorkspacePackages(new Project(fs, cwd), ['./apps/deep/**', '!./apps/deep/a'])).toMatchObject([
{ path: join('apps/deep/b'), name: 'b' },
{ path: join('apps/deep/c'), name: 'c' },
])
})
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ export async function getWorkspacePackages(project: Project, patterns: string[]
const results = (
await Promise.all(
patterns.map((pattern) => {
const matcher = new Minimatch(pattern)
const cleanedPattern = pattern.replace(/^!?(\.\/)/, (match, p1) => match.replace(p1, ''))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe leave a comment here explaining why this is needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if anyone would ever want to use a path starting with ../? πŸ€”

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it's the root of the workspace I don't think it make any sense

const matcher = new Minimatch(cleanedPattern)
if (matcher.negate) {
return
}
Expand All @@ -118,7 +119,8 @@ export async function getWorkspacePackages(project: Project, patterns: string[]

for (const result of results) {
for (const pattern of patterns) {
const matcher = new Minimatch(pattern)
const cleanedPattern = pattern.replace(/^!?(\.\/)/, (match, p1) => match.replace(p1, ''))
const matcher = new Minimatch(cleanedPattern)
if (minimatch(result.path, matcher.pattern)) {
filtered.set(project.fs.join(result.path), result)
if (matcher.negate) {
Expand Down