Skip to content

Commit

Permalink
Revert "feat(core): support finding matching projects with only negat…
Browse files Browse the repository at this point in the history
…ive patterns (#22743)" (#23459)

This reverts commit 8975786.

Fixes #23458

(cherry picked from commit 312b271)
  • Loading branch information
AgentEnder authored and FrozenPandaz committed May 21, 2024
1 parent 40aca15 commit 37c1497
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 31 deletions.
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

0 comments on commit 37c1497

Please sign in to comment.