OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |