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..a608f1187fecc040d4288e699493c0be3a2df2aa 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,23 @@ Future invokeCommand(String cacheDir, ArgResults mainOptions) { |
'Command "${options.name}" does not take any arguments.'); |
} |
- return syncFuture(() { |
- return command.run(cacheDir, mainOptions, options); |
- }).whenComplete(() { |
+ try { |
+ await command.run(cacheDir, mainOptions, options); |
+ } 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.'); |
+ return flushThenExit(exit_codes.USAGE); |
nweiz
2014/08/29 23:30:41
"return" -> "await"
Bob Nystrom
2014/09/03 23:44:16
Done.
|
+ } |
} |