More strong-mode fixes
diff --git a/pkgs/package_config/CHANGELOG.md b/pkgs/package_config/CHANGELOG.md
index f4e355e..6ac42ec 100644
--- a/pkgs/package_config/CHANGELOG.md
+++ b/pkgs/package_config/CHANGELOG.md
@@ -1,16 +1,15 @@
-# Changelog
+## 0.1.4
-## 0.1.3-dev
+- Strong mode fixes.
-- Invalid test cleanup (to keepup with changes in `Uri`).
+## 0.1.3
+
+- Invalid test cleanup (to keep up with changes in `Uri`).
## 0.1.1
- Syntax updates.
-
## 0.1.0
- Initial implementation.
-
-
diff --git a/pkgs/package_config/lib/discovery.dart b/pkgs/package_config/lib/discovery.dart
index 10dbb8e..4c09eec 100644
--- a/pkgs/package_config/lib/discovery.dart
+++ b/pkgs/package_config/lib/discovery.dart
@@ -28,19 +28,19 @@
/// resolution file, for example one specified using a `--packages`
/// command-line parameter.
Future<Packages> loadPackagesFile(Uri packagesFile,
- {Future<List<int>> loader(Uri uri)}) {
+ {Future<List<int>> loader(Uri uri)}) async {
Packages parseBytes(List<int> bytes) {
Map<String, Uri> packageMap = pkgfile.parse(bytes, packagesFile);
return new MapPackages(packageMap);
}
if (packagesFile.scheme == "file") {
File file = new File.fromUri(packagesFile);
- return file.readAsBytes().then(parseBytes);
+ return parseBytes(await file.readAsBytes());
}
if (loader == null) {
- return _httpGet(packagesFile).then(parseBytes);
+ return parseBytes(await _httpGet(packagesFile));
}
- return loader(packagesFile).then(parseBytes);
+ return parseBytes(await loader(packagesFile));
}
/// Create a [Packages] object for a package directory.
@@ -189,17 +189,19 @@
/// of the requested `.packages` file as bytes, which will be assumed to be
/// UTF-8 encoded.
Future<Packages> findPackagesFromNonFile(Uri nonFileUri,
- {Future<List<int>> loader(Uri name)}) {
+ {Future<List<int>> loader(Uri name)}) async {
if (loader == null) loader = _httpGet;
Uri packagesFileUri = nonFileUri.resolve(".packages");
- return loader(packagesFileUri).then((List<int> fileBytes) {
+
+ try {
+ List<int> fileBytes = await loader(packagesFileUri);
Map<String, Uri> map = pkgfile.parse(fileBytes, packagesFileUri);
return new MapPackages(map);
- }, onError: (_) {
+ } catch (_) {
// Didn't manage to load ".packages". Assume a "packages/" directory.
Uri packagesDirectoryUri = nonFileUri.resolve("packages/");
return new NonFilePackagesDirectoryPackages(packagesDirectoryUri);
- });
+ }
}
/// Fetches a file over http.
diff --git a/pkgs/package_config/pubspec.yaml b/pkgs/package_config/pubspec.yaml
index f2c4e06..80aea6d 100644
--- a/pkgs/package_config/pubspec.yaml
+++ b/pkgs/package_config/pubspec.yaml
@@ -1,5 +1,5 @@
name: package_config
-version: 0.1.3
+version: 0.1.4
description: Support for working with Package Resolution config files.
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/package_config