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

Unified Diff: sdk/lib/_internal/pub/bin/pub.dart

Issue 521643005: Convert more pub code to use async/await. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise! Created 6 years, 3 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
Index: sdk/lib/_internal/pub/bin/pub.dart
diff --git a/sdk/lib/_internal/pub/bin/pub.dart b/sdk/lib/_internal/pub/bin/pub.dart
index 8f7fa4e32ddb192e82476c190c4953617b49973d..67cefeb189a5d5967ce539e8d71974987a9478d5 100644
--- a/sdk/lib/_internal/pub/bin/pub.dart
+++ b/sdk/lib/_internal/pub/bin/pub.dart
@@ -129,7 +129,7 @@ int chooseExitCode(exception) {
}
/// Walks the command tree and runs the selected pub command.
-Future invokeCommand(String cacheDir, ArgResults mainOptions) {
+Future invokeCommand(String cacheDir, ArgResults mainOptions) async {
var commands = PubCommand.mainCommands;
var command;
var commandString = "pub";
@@ -174,26 +174,25 @@ Future invokeCommand(String cacheDir, ArgResults mainOptions) {
'Command "${options.name}" does not take any arguments.');
}
- return syncFuture(() {
+ try {
+ // TODO(rnystrom): Use await here when this is fixed:
+ // https://github.com/dart-lang/async_await/issues/40.
return command.run(cacheDir, mainOptions, options);
- }).whenComplete(() {
+ } finally {
command.cache.deleteTempDir();
- });
+ }
}
/// Checks that pub is running on a supported platform.
///
/// If it isn't, it prints an error message and exits. Completes when the
/// validation is done.
-Future validatePlatform() {
- return syncFuture(() {
- if (Platform.operatingSystem != 'windows') return null;
-
- return runProcess('ver', []).then((result) {
- if (result.stdout.join('\n').contains('XP')) {
- log.error('Sorry, but pub is not supported on Windows XP.');
- return flushThenExit(exit_codes.USAGE);
- }
- });
- });
+Future validatePlatform() async {
+ if (Platform.operatingSystem != 'windows') return;
+
+ var result = await runProcess('ver', []);
+ if (result.stdout.join('\n').contains('XP')) {
+ log.error('Sorry, but pub is not supported on Windows XP.');
+ await flushThenExit(exit_codes.USAGE);
+ }
}
« no previous file with comments | « sdk/lib/_internal/pub/bin/async_compile.dart ('k') | sdk/lib/_internal/pub/lib/src/command/cache_repair.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698