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 defer(() { | 148 return new Future.of(() { |
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 if (globalOptions['trace'] && trace != null) { | 258 if (globalOptions['trace'] && trace != null) { |
259 log.error(trace); | 259 log.error(trace); |
260 log.dumpTranscript(); | 260 log.dumpTranscript(); |
261 } else { | 261 } else { |
262 log.fine(trace); | 262 log.fine(trace); |
263 } | 263 } |
264 | 264 |
265 exit(_chooseExitCode(error)); | 265 exit(_chooseExitCode(error)); |
266 } | 266 } |
267 | 267 |
268 defer(() { | 268 new Future.of(() { |
269 if (requiresEntrypoint) { | 269 if (requiresEntrypoint) { |
270 // TODO(rnystrom): Will eventually need better logic to walk up | 270 // TODO(rnystrom): Will eventually need better logic to walk up |
271 // subdirectories until we hit one that looks package-like. For now, | 271 // subdirectories until we hit one that looks package-like. For now, |
272 // just assume the cwd is it. | 272 // just assume the cwd is it. |
273 entrypoint = new Entrypoint(path.current, cache); | 273 entrypoint = new Entrypoint(path.current, cache); |
274 } | 274 } |
275 | 275 |
276 var commandFuture = onRun(); | 276 var commandFuture = onRun(); |
277 if (commandFuture == null) return true; | 277 if (commandFuture == null) return true; |
278 | 278 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 if (exception is HttpException || exception is HttpParserException || | 322 if (exception is HttpException || exception is HttpParserException || |
323 exception is SocketIOException || exception is PubHttpException) { | 323 exception is SocketIOException || exception is PubHttpException) { |
324 return exit_codes.UNAVAILABLE; | 324 return exit_codes.UNAVAILABLE; |
325 } else if (exception is FormatException) { | 325 } else if (exception is FormatException) { |
326 return exit_codes.DATA; | 326 return exit_codes.DATA; |
327 } else { | 327 } else { |
328 return 1; | 328 return 1; |
329 } | 329 } |
330 } | 330 } |
331 } | 331 } |
OLD | NEW |