Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: utils/pub/sdk_source.dart

Issue 12079112: Make a bunch of stuff in pub synchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix after merge. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/pub/pub.dart ('k') | utils/pub/source.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/sdk_source.dart
diff --git a/utils/pub/sdk_source.dart b/utils/pub/sdk_source.dart
index e0782b08cc3d0494c96f2d9c8b2d4b89c70ddeeb..124d2651bb1cd76d066ac412e0ff67a05bcd133a 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,10 @@ 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) {
+ 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 +34,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;
}
}
« no previous file with comments | « utils/pub/pub.dart ('k') | utils/pub/source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698