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

Unified Diff: utils/pub/pub.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/package.dart ('k') | utils/pub/sdk_source.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/pub.dart
diff --git a/utils/pub/pub.dart b/utils/pub/pub.dart
index dcd76c68c4d8895399ab7c5702362109e6c6775f..db628d03157cdb811e2d28078b7397952053c0fa 100644
--- a/utils/pub/pub.dart
+++ b/utils/pub/pub.dart
@@ -235,43 +235,34 @@ abstract class PubCommand {
exit(_chooseExitCode(error));
}
- var future = new Future.immediate(null);
- if (requiresEntrypoint) {
- // TODO(rnystrom): Will eventually need better logic to walk up
- // subdirectories until we hit one that looks package-like. For now, just
- // assume the cwd is it.
- future = Entrypoint.load(path.current, cache);
- }
-
- future = future.then((entrypoint) {
- this.entrypoint = entrypoint;
- try {
- var commandFuture = onRun();
- if (commandFuture == null) return true;
+ defer(() {
+ if (requiresEntrypoint) {
+ // TODO(rnystrom): Will eventually need better logic to walk up
+ // subdirectories until we hit one that looks package-like. For now,
+ // just assume the cwd is it.
+ entrypoint = new Entrypoint(path.current, cache);
+ }
- return commandFuture;
- } catch (error, trace) {
- handleError(error, trace);
+ var commandFuture = onRun();
+ if (commandFuture == null) return true;
+
+ return commandFuture;
+ }).whenComplete(() => cache_.deleteTempDir()).catchError((asyncError) {
+ var e = asyncError.error;
+ if (e is PubspecNotFoundException && e.name == null) {
+ e = 'Could not find a file named "pubspec.yaml" in the directory '
+ '${path.current}.';
+ } else if (e is PubspecHasNoNameException && e.name == null) {
+ e = 'pubspec.yaml is missing the required "name" field (e.g. "name: '
+ '${basename(path.current)}").';
}
- });
- future
- .then((_) => cache_.deleteTempDir())
- .catchError((asyncError) {
- var e = asyncError.error;
- if (e is PubspecNotFoundException && e.name == null) {
- e = 'Could not find a file named "pubspec.yaml" in the directory '
- '${path.current}.';
- } else if (e is PubspecHasNoNameException && e.name == null) {
- e = 'pubspec.yaml is missing the required "name" field (e.g. "name: '
- '${basename(path.current)}").';
- }
-
- handleError(e, asyncError.stackTrace);
- })
+ handleError(e, asyncError.stackTrace);
+ }).then((_) {
// Explicitly exit on success to ensure that any dangling dart:io handles
// don't cause the process to never terminate.
- .then((_) => exit(0));
+ exit(0);
+ });
}
/// Override this to perform the specific command. Return a future that
« no previous file with comments | « utils/pub/package.dart ('k') | utils/pub/sdk_source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698