fix: dedup temporary selections

This commit is contained in:
Cheng Liu 2024-05-09 17:44:12 -07:00
parent b8bec76c35
commit f6df534f02
No known key found for this signature in database
GPG key ID: EEC8452F7DB85CD6

View file

@ -344,18 +344,25 @@ ${availableProfiles.join(',')}
const fromSelector: Set<string> = fromProjects || new Set(); const fromSelector: Set<string> = fromProjects || new Set();
// If Rush Selector --to <projects> is specified, using `git sparse-checkout add` to add folders of the projects specified // If Rush Selector --to <projects> is specified, using `git sparse-checkout add` to add folders of the projects specified
const projectsSelections: ISelection[] = [...rushSelectorState]; const projectsSelections: ISelection[] = [...rushSelectorState];
const existingSelections: Set<string> = new Set<string>(
rushSelectorState.map(({ selector, argument }) => `${selector}$$${argument}`)
);
for (const project of toSelector) { for (const project of toSelector) {
projectsSelections.push({ if (!existingSelections.has(`--to$$${project}`)) {
selector: '--to', projectsSelections.push({
argument: project selector: '--to',
}); argument: project
});
}
} }
for (const project of fromSelector) { for (const project of fromSelector) {
projectsSelections.push({ if (!existingSelections.has(`--from$$${project}`)) {
selector: '--from', projectsSelections.push({
argument: project selector: '--from',
}); argument: project
});
}
} }
if (projectsSelections.length > 0) { if (projectsSelections.length > 0) {