in lib/src/resolver.dart [87:114]
static Map<String, Uri> _parsePackages(String packagesPath) {
final content = File(packagesPath).readAsStringSync();
try {
final parsed =
PackageConfig.parseString(content, Uri.base.resolve(packagesPath));
return {
for (var package in parsed.packages)
package.name: package.packageUriRoot
};
} on FormatException catch (_) {
// It was probably an old style .packages file
final lines = LineSplitter.split(content);
final packageMap = <String, Uri>{};
for (var line in lines) {
if (line.startsWith('#')) continue;
final firstColon = line.indexOf(':');
if (firstColon == -1) {
throw FormatException(
'Unexpected package config format, expected an old style '
'.packages file or new style package_config.json file.',
content);
}
packageMap[line.substring(0, firstColon)] =
Uri.parse(line.substring(firstColon + 1, line.length));
}
return packageMap;
}
}