| Index: utils/pub/sdk_source.dart
|
| diff --git a/utils/pub/sdk_source.dart b/utils/pub/sdk_source.dart
|
| index e0782b08cc3d0494c96f2d9c8b2d4b89c70ddeeb..0db2cf89b7385b77bedc8bf8fef974c584f7f273 100644
|
| --- a/utils/pub/sdk_source.dart
|
| +++ b/utils/pub/sdk_source.dart
|
| @@ -10,6 +10,7 @@ import 'package.dart';
|
| import 'pubspec.dart';
|
| import 'sdk.dart' as sdk;
|
| import 'source.dart';
|
| +import 'utils.dart';
|
| import 'version.dart';
|
|
|
| /// A package source that uses libraries from the Dart SDK.
|
| @@ -20,10 +21,11 @@ class SdkSource extends Source {
|
| /// SDK packages are not individually versioned. Instead, their version is
|
| /// inferred from the revision number of the SDK itself.
|
| Future<Pubspec> describe(PackageId id) {
|
| - return _getPackagePath(id).then((packageDir) {
|
| + // Make sure all errors propagate through future.
|
| + return defer(() {
|
| + var packageDir = _getPackagePath(id);
|
| // TODO(rnystrom): What if packageDir is null?
|
| - return Package.load(id.name, packageDir, systemCache.sources);
|
| - }).then((package) {
|
| + var package = new Package(id.name, packageDir, systemCache.sources);
|
| // Ignore the pubspec's version, and use the SDK's.
|
| return new Pubspec(id.name, sdk.version, package.pubspec.dependencies,
|
| package.pubspec.environment);
|
| @@ -33,18 +35,18 @@ class SdkSource extends Source {
|
| /// Since all the SDK files are already available locally, installation just
|
| /// involves symlinking the SDK library into the packages directory.
|
| Future<bool> install(PackageId id, String destPath) {
|
| - return _getPackagePath(id).then((path) {
|
| - if (path == null) return new Future<bool>.immediate(false);
|
| + return defer(() {
|
| + var path = _getPackagePath(id);
|
| + if (path == null) return false;
|
|
|
| - return createPackageSymlink(id.name, path, destPath).then(
|
| - (_) => true);
|
| + return createPackageSymlink(id.name, path, destPath).then((_) => true);
|
| });
|
| }
|
|
|
| /// Gets the path in the SDK's "pkg" directory to the directory containing
|
| /// package [id]. Returns `null` if the package could not be found.
|
| - Future<String> _getPackagePath(PackageId id) {
|
| + String _getPackagePath(PackageId id) {
|
| var pkgPath = join(sdk.rootDirectory, "pkg", id.description);
|
| - return dirExists(pkgPath).then((found) => found ? pkgPath : null);
|
| + return dirExists(pkgPath) ? pkgPath : null;
|
| }
|
| }
|
|
|