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

Side by Side Diff: utils/pub/pub.dart

Issue 14070010: Refactor Future constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added co19 issue number. Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/pub/path_source.dart ('k') | utils/pub/source.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// The main entrypoint for the pub command line application. 5 /// The main entrypoint for the pub command line application.
6 library pub; 6 library pub;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:math'; 10 import 'dart:math';
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 138 }
139 139
140 var commandArgs = globalOptions.rest.sublist(1); 140 var commandArgs = globalOptions.rest.sublist(1);
141 command.run(cache, globalOptions, commandArgs); 141 command.run(cache, globalOptions, commandArgs);
142 }); 142 });
143 } 143 }
144 144
145 /// Checks that pub is running on a supported platform. If it isn't, it prints 145 /// Checks that pub is running on a supported platform. If it isn't, it prints
146 /// an error message and exits. Completes when the validation is done. 146 /// an error message and exits. Completes when the validation is done.
147 Future validatePlatform() { 147 Future validatePlatform() {
148 return new Future.of(() { 148 return new Future.sync(() {
149 if (Platform.operatingSystem != 'windows') return; 149 if (Platform.operatingSystem != 'windows') return;
150 150
151 return runProcess('ver', []).then((result) { 151 return runProcess('ver', []).then((result) {
152 if (result.stdout.join('\n').contains('XP')) { 152 if (result.stdout.join('\n').contains('XP')) {
153 log.error('Sorry, but pub is not supported on Windows XP.'); 153 log.error('Sorry, but pub is not supported on Windows XP.');
154 exit(exit_codes.USAGE); 154 exit(exit_codes.USAGE);
155 } 155 }
156 }); 156 });
157 }); 157 });
158 } 158 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 if (globalOptions['trace'] && trace != null) { 260 if (globalOptions['trace'] && trace != null) {
261 log.error(trace); 261 log.error(trace);
262 log.dumpTranscript(); 262 log.dumpTranscript();
263 } else { 263 } else {
264 log.fine(trace); 264 log.fine(trace);
265 } 265 }
266 266
267 exit(_chooseExitCode(error)); 267 exit(_chooseExitCode(error));
268 } 268 }
269 269
270 new Future.of(() { 270 new Future.sync(() {
271 if (requiresEntrypoint) { 271 if (requiresEntrypoint) {
272 // TODO(rnystrom): Will eventually need better logic to walk up 272 // TODO(rnystrom): Will eventually need better logic to walk up
273 // subdirectories until we hit one that looks package-like. For now, 273 // subdirectories until we hit one that looks package-like. For now,
274 // just assume the cwd is it. 274 // just assume the cwd is it.
275 entrypoint = new Entrypoint(path.current, cache); 275 entrypoint = new Entrypoint(path.current, cache);
276 } 276 }
277 277
278 var commandFuture = onRun(); 278 var commandFuture = onRun();
279 if (commandFuture == null) return true; 279 if (commandFuture == null) return true;
280 280
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 if (exception is HttpException || exception is HttpParserException || 323 if (exception is HttpException || exception is HttpParserException ||
324 exception is SocketIOException || exception is PubHttpException) { 324 exception is SocketIOException || exception is PubHttpException) {
325 return exit_codes.UNAVAILABLE; 325 return exit_codes.UNAVAILABLE;
326 } else if (exception is FormatException) { 326 } else if (exception is FormatException) {
327 return exit_codes.DATA; 327 return exit_codes.DATA;
328 } else { 328 } else {
329 return 1; 329 return 1;
330 } 330 }
331 } 331 }
332 } 332 }
OLDNEW
« no previous file with comments | « utils/pub/path_source.dart ('k') | utils/pub/source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698