Chromium Code Reviews| 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 '../../pkg/args/lib/args.dart'; | 9 import '../../pkg/args/lib/args.dart'; |
| 10 import '../../pkg/path/lib/path.dart' as path; | 10 import '../../pkg/path/lib/path.dart' as path; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 } | 231 } |
| 232 | 232 |
| 233 exit(_chooseExitCode(error)); | 233 exit(_chooseExitCode(error)); |
| 234 } | 234 } |
| 235 | 235 |
| 236 var future = new Future.immediate(null); | 236 var future = new Future.immediate(null); |
| 237 if (requiresEntrypoint) { | 237 if (requiresEntrypoint) { |
| 238 // TODO(rnystrom): Will eventually need better logic to walk up | 238 // TODO(rnystrom): Will eventually need better logic to walk up |
| 239 // subdirectories until we hit one that looks package-like. For now, just | 239 // subdirectories until we hit one that looks package-like. For now, just |
| 240 // assume the cwd is it. | 240 // assume the cwd is it. |
| 241 future = Entrypoint.load(path.current, cache); | 241 future = defer(() => new Entrypoint(path.current, cache)); |
|
nweiz
2013/02/01 02:05:55
I think this slightly arcane control flow is an ar
Bob Nystrom
2013/02/01 23:17:21
Beautiful. Tweaked it a bit more, but that's great
| |
| 242 } | 242 } |
| 243 | 243 |
| 244 future = future.then((entrypoint) { | 244 future = future.then((entrypoint) { |
| 245 this.entrypoint = entrypoint; | 245 this.entrypoint = entrypoint; |
| 246 try { | 246 try { |
| 247 var commandFuture = onRun(); | 247 var commandFuture = onRun(); |
| 248 if (commandFuture == null) return true; | 248 if (commandFuture == null) return true; |
| 249 | 249 |
| 250 return commandFuture; | 250 return commandFuture; |
| 251 } catch (error, trace) { | 251 } catch (error, trace) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 if (exception is HttpException || exception is HttpParserException || | 299 if (exception is HttpException || exception is HttpParserException || |
| 300 exception is SocketIOException || exception is PubHttpException) { | 300 exception is SocketIOException || exception is PubHttpException) { |
| 301 return exit_codes.UNAVAILABLE; | 301 return exit_codes.UNAVAILABLE; |
| 302 } else if (exception is FormatException) { | 302 } else if (exception is FormatException) { |
| 303 return exit_codes.DATA; | 303 return exit_codes.DATA; |
| 304 } else { | 304 } else { |
| 305 return 1; | 305 return 1; |
| 306 } | 306 } |
| 307 } | 307 } |
| 308 } | 308 } |
| OLD | NEW |