addPackage method
Adds a package to this PackageMap, returning a new PackageMap.
If a package with the same name already exists, a warning is logged and the existing package is kept.
Implementation
PackageMap addPackage(Package package) {
final combinedMap = Map<String, Package>.from(_map);
if (!combinedMap.containsKey(package.name)) {
combinedMap[package.name] = package;
} else {
_logger.warning(
'Package "${package.name}" has the same name as an existing '
'workspace package. New package will be ignored. Consider renaming '
'one of the packages to avoid this conflict.',
);
}
return PackageMap(combinedMap, _logger);
}