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

Unified Diff: utils/pub/pub.dart

Issue 12221049: Don't allow pub to run on XP. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | « no previous file | no next file » | 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 db628d03157cdb811e2d28078b7397952053c0fa..302420ffc184bf0baed30a298309420644a1bfe3 100644
--- a/utils/pub/pub.dart
+++ b/utils/pub/pub.dart
@@ -121,20 +121,37 @@ main() {
cacheDir = '${Platform.environment['HOME']}/.pub-cache';
}
- var cache = new SystemCache.withSources(cacheDir);
+ validatePlatform().then((_) {
+ var cache = new SystemCache.withSources(cacheDir);
+
+ // Select the command.
+ var command = pubCommands[globalOptions.rest[0]];
+ if (command == null) {
+ log.error('Could not find a command named "${globalOptions.rest[0]}".');
+ log.error('Run "pub help" to see available commands.');
+ exit(exit_codes.USAGE);
+ return;
+ }
- // Select the command.
- var command = pubCommands[globalOptions.rest[0]];
- if (command == null) {
- log.error('Could not find a command named "${globalOptions.rest[0]}".');
- log.error('Run "pub help" to see available commands.');
- exit(exit_codes.USAGE);
- return;
- }
+ var commandArgs =
+ globalOptions.rest.getRange(1, globalOptions.rest.length - 1);
+ command.run(cache, globalOptions, commandArgs);
+ });
+}
+
+/// 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 defer(() {
+ if (Platform.operatingSystem != 'windows') return;
- var commandArgs =
- globalOptions.rest.getRange(1, globalOptions.rest.length - 1);
- command.run(cache, globalOptions, commandArgs);
+ return runProcess('ver', []).then((result) {
+ if (result.stdout.join('\n').contains('XP')) {
+ log.error('Sorry, but pub is not supported on Windows XP.');
+ exit(exit_codes.USAGE);
+ }
+ });
+ });
}
/// Displays usage information for the app.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698