| 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 /** | 5 /** |
| 6 * The main entrypoint for the pub command line application. | 6 * The main entrypoint for the pub command line application. |
| 7 */ | 7 */ |
| 8 library pub; | 8 library pub; |
| 9 | 9 |
| 10 import '../../pkg/args/lib/args.dart'; | 10 import '../../pkg/args/lib/args.dart'; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 197 } |
| 198 | 198 |
| 199 exit(_chooseExitCode(error)); | 199 exit(_chooseExitCode(error)); |
| 200 } | 200 } |
| 201 | 201 |
| 202 var future = new Future.immediate(null); | 202 var future = new Future.immediate(null); |
| 203 if (requiresEntrypoint) { | 203 if (requiresEntrypoint) { |
| 204 // TODO(rnystrom): Will eventually need better logic to walk up | 204 // TODO(rnystrom): Will eventually need better logic to walk up |
| 205 // subdirectories until we hit one that looks package-like. For now, just | 205 // subdirectories until we hit one that looks package-like. For now, just |
| 206 // assume the cwd is it. | 206 // assume the cwd is it. |
| 207 future = Package.load(null, workingDir, cache.sources) | 207 future = Package.load(null, currentWorkingDir, cache.sources) |
| 208 .transform((package) => new Entrypoint(package, cache)); | 208 .transform((package) => new Entrypoint(package, cache)); |
| 209 } | 209 } |
| 210 | 210 |
| 211 future = future.chain((entrypoint) { | 211 future = future.chain((entrypoint) { |
| 212 this.entrypoint = entrypoint; | 212 this.entrypoint = entrypoint; |
| 213 try { | 213 try { |
| 214 var commandFuture = onRun(); | 214 var commandFuture = onRun(); |
| 215 if (commandFuture == null) return new Future.immediate(true); | 215 if (commandFuture == null) return new Future.immediate(true); |
| 216 | 216 |
| 217 return commandFuture; | 217 return commandFuture; |
| 218 } catch (error, trace) { | 218 } catch (error, trace) { |
| 219 handleError(error, trace); | 219 handleError(error, trace); |
| 220 return new Future.immediate(null); | 220 return new Future.immediate(null); |
| 221 } | 221 } |
| 222 }); | 222 }); |
| 223 | 223 |
| 224 future = future.chain((_) => cache_.deleteTempDir()); | 224 future = future.chain((_) => cache_.deleteTempDir()); |
| 225 | 225 |
| 226 future.handleException((e) { | 226 future.handleException((e) { |
| 227 if (e is PubspecNotFoundException && e.name == null) { | 227 if (e is PubspecNotFoundException && e.name == null) { |
| 228 e = 'Could not find a file named "pubspec.yaml" in the directory ' | 228 e = 'Could not find a file named "pubspec.yaml" in the directory ' |
| 229 '$workingDir.'; | 229 '$currentWorkingDir.'; |
| 230 } else if (e is PubspecHasNoNameException && e.name == null) { | 230 } else if (e is PubspecHasNoNameException && e.name == null) { |
| 231 e = 'pubspec.yaml is missing the required "name" field (e.g. "name: ' | 231 e = 'pubspec.yaml is missing the required "name" field (e.g. "name: ' |
| 232 '${basename(workingDir)}").'; | 232 '${basename(currentWorkingDir)}").'; |
| 233 } | 233 } |
| 234 | 234 |
| 235 handleError(e, future.stackTrace); | 235 handleError(e, future.stackTrace); |
| 236 }); | 236 }); |
| 237 | 237 |
| 238 // Explicitly exit on success to ensure that any dangling dart:io handles | 238 // Explicitly exit on success to ensure that any dangling dart:io handles |
| 239 // don't cause the process to never terminate. | 239 // don't cause the process to never terminate. |
| 240 future.then((_) => exit(0)); | 240 future.then((_) => exit(0)); |
| 241 } | 241 } |
| 242 | 242 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 267 if (exception is HttpException || exception is HttpParserException || | 267 if (exception is HttpException || exception is HttpParserException || |
| 268 exception is SocketIOException || exception is PubHttpException) { | 268 exception is SocketIOException || exception is PubHttpException) { |
| 269 return exit_codes.UNAVAILABLE; | 269 return exit_codes.UNAVAILABLE; |
| 270 } else if (exception is FormatException) { | 270 } else if (exception is FormatException) { |
| 271 return exit_codes.DATA; | 271 return exit_codes.DATA; |
| 272 } else { | 272 } else { |
| 273 return 1; | 273 return 1; |
| 274 } | 274 } |
| 275 } | 275 } |
| 276 } | 276 } |
| OLD | NEW |