Skip to content

Instantly share code, notes, and snippets.

@BlackHC
Created January 14, 2017 18:29
Show Gist options
  • Save BlackHC/a26b0a3742d1814d7f7c58adc53b8179 to your computer and use it in GitHub Desktop.
Save BlackHC/a26b0a3742d1814d7f7c58adc53b8179 to your computer and use it in GitHub Desktop.
Merging package configs
import 'package:package_resolver/package_resolver.dart';
Future<PackageResolver> mergePackageConfigs(String otherPackageRoot) async {
final currentConfig = await PackageResolver.current.packageConfigMap;
final otherConfig =
(await SyncPackageResolver.loadConfig(otherPackageRoot + '/.packages'))
.packageConfigMap;
// We do something horrible here: We simply merge the current config with
// the other. Hoping it will still work..
final config = <String, Uri>{};
config.addAll(currentConfig);
config.addAll(otherConfig);
return new PackageResolver.config(config);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment