fn match_package_names(
    name_pattern: &str,
    all_packages: &HashSet<PackageName>,
    mut packages: HashMap<PackageName, PackageInclusionReason>,
) -> Result<HashMap<PackageName, PackageInclusionReason>, ResolutionError> {
    let matcher = SimpleGlob::new(name_pattern)?;
    let matched_packages = all_packages
        .iter()
        .filter(|e| matcher.is_match(e.as_ref()))
        .cloned()
        .collect::<HashSet<_>>();

    // If the pattern was an exact name and it matched no packages, then error
    if matcher.is_exact() && matched_packages.is_empty() {
        return Err(ResolutionError::NoPackagesMatchedWithName(
            name_pattern.to_owned(),
        ));
    }

    packages.retain(|pkg, _| matched_packages.contains(pkg));

    Ok(packages)
}
match the provided name pattern against the provided set of packages
and return the set of packages that match the pattern

the pattern is normalized, replacing `\*` with `.*`
crates/turborepo-lib/src/run/scope/filter.rs