-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup(core): add e2e tests for new implicit dependencies definitions
- Loading branch information
1 parent
ca87f32
commit d0123c1
Showing
6 changed files
with
106 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import minimatch = require('minimatch'); | ||
|
||
export function findMatchingProjects( | ||
patterns: string[], | ||
projectNames: string[] | ||
): string[] { | ||
const selectedProjects: Set<string> = new Set(); | ||
const excludedProjects: Set<string> = new Set(); | ||
for (const nameOrGlob of patterns) { | ||
if (projectNames.includes(nameOrGlob)) { | ||
selectedProjects.add(nameOrGlob); | ||
continue; | ||
} | ||
|
||
const exclude = nameOrGlob.startsWith('!'); | ||
const pattern = exclude ? nameOrGlob.substring(1) : nameOrGlob; | ||
|
||
const matchedProjectNames = minimatch.match(projectNames, pattern); | ||
|
||
if (matchedProjectNames.length === 0) { | ||
throw new Error(`No projects matching: ${nameOrGlob}`); | ||
} | ||
|
||
matchedProjectNames.forEach((matchedProjectName) => { | ||
if (exclude) { | ||
excludedProjects.add(matchedProjectName); | ||
} else { | ||
selectedProjects.add(matchedProjectName); | ||
} | ||
}); | ||
} | ||
|
||
for (const project of excludedProjects) { | ||
selectedProjects.delete(project); | ||
} | ||
|
||
return Array.from(selectedProjects); | ||
} |