From 5d8839a7dd42a4e7eefbe77a67dca8d1b6d9bced Mon Sep 17 00:00:00 2001 From: Craigory Coppola Date: Mon, 24 Apr 2023 18:37:22 -0400 Subject: [PATCH] chore(core): cleanup some code in find-matching-projects (#16523) --- packages/nx/src/utils/find-matching-projects.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/nx/src/utils/find-matching-projects.ts b/packages/nx/src/utils/find-matching-projects.ts index 87c1facca963c..3b988e9836277 100644 --- a/packages/nx/src/utils/find-matching-projects.ts +++ b/packages/nx/src/utils/find-matching-projects.ts @@ -90,7 +90,10 @@ export function findMatchingProjects( // Same thing as `type:unlabeled`. If no specific type is set, // we can waterfall through the different types until we find a match default: { - const size = selectedProjects.size + excludedProjects.size; + // The size of the selected and excluded projects set, before we + // start updating it with this pattern. If the size changes, we + // know we found a match and can skip the other types. + const originalSize = selectedProjects.size + excludedProjects.size; addMatchingProjectsByName( projectNames, projects, @@ -98,7 +101,7 @@ export function findMatchingProjects( excludedProjects, selectedProjects ); - if (selectedProjects.size + excludedProjects.size > size) { + if (selectedProjects.size + excludedProjects.size > originalSize) { // There was some match by name, don't check other types continue; } @@ -109,7 +112,7 @@ export function findMatchingProjects( excludedProjects, selectedProjects ); - if (selectedProjects.size + excludedProjects.size > size) { + if (selectedProjects.size + excludedProjects.size > originalSize) { // There was some match by directory, don't check other types // Note - this doesn't do anything currently, but preps for future // types