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

Revert "feat(core): support finding matching projects with only negative patterns (#22743)" #23459

Merged
merged 1 commit into from
May 16, 2024
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
16 changes: 0 additions & 16 deletions packages/nx/src/utils/find-matching-projects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,6 @@ describe('findMatchingProjects', () => {
'nested',
]);
});

it('should support "all except" style patterns', () => {
expect(findMatchingProjects(['!a'], projectGraph)).toEqual([
'test-project',
'b',
'c',
'nested',
]);
expect(findMatchingProjects(['!tag:api'], projectGraph)).toEqual([
'b',
'nested',
]);
expect(
findMatchingProjects(['!tag:api', 'test-project'], projectGraph)
).toEqual(['b', 'nested', 'test-project']);
});
});

const projects = [
Expand Down
16 changes: 1 addition & 15 deletions packages/nx/src/utils/find-matching-projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ export function findMatchingProjects(

const matchedProjects: Set<string> = new Set();

// If the first pattern is an exclude pattern,
// we add a wildcard pattern at the first to select
// all projects, except the ones that match the exclude pattern.
// e.g. ['!tag:someTag', 'project2'] will match all projects except
// the ones with the tag 'someTag', and also match the project 'project2',
// regardless of its tags.
if (isExcludePattern(patterns[0])) {
patterns.unshift('*');
}

for (const stringPattern of patterns) {
if (!stringPattern.length) {
continue;
Expand Down Expand Up @@ -215,15 +205,11 @@ function addMatchingProjectsByTag(
}
}

function isExcludePattern(pattern: string): boolean {
return pattern.startsWith('!');
}

function parseStringPattern(
pattern: string,
projects: Record<string, ProjectGraphProjectNode>
): ProjectPattern {
const isExclude = isExcludePattern(pattern);
const isExclude = pattern.startsWith('!');

// Support for things like: `!{type}:value`
if (isExclude) {
Expand Down