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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 } catch (error, trace) { | 255 } catch (error, trace) { |
256 handleError(error, trace); | 256 handleError(error, trace); |
257 return new Future.immediate(null); | 257 return new Future.immediate(null); |
258 } | 258 } |
259 }); | 259 }); |
260 | 260 |
261 | 261 |
262 future | 262 future |
263 .then((_) => cache_.deleteTempDir()) | 263 .then((_) => cache_.deleteTempDir()) |
264 .catchError((asyncError) { | 264 .catchError((asyncError) { |
265 var e = getRealError(asyncError); | 265 var e = asyncError.error; |
266 if (e is PubspecNotFoundException && e.name == null) { | 266 if (e is PubspecNotFoundException && e.name == null) { |
267 e = 'Could not find a file named "pubspec.yaml" in the directory ' | 267 e = 'Could not find a file named "pubspec.yaml" in the directory ' |
268 '${path.current}.'; | 268 '${path.current}.'; |
269 } else if (e is PubspecHasNoNameException && e.name == null) { | 269 } else if (e is PubspecHasNoNameException && e.name == null) { |
270 e = 'pubspec.yaml is missing the required "name" field (e.g. "name: ' | 270 e = 'pubspec.yaml is missing the required "name" field (e.g. "name: ' |
271 '${basename(path.current)}").'; | 271 '${basename(path.current)}").'; |
272 } | 272 } |
273 | 273 |
274 handleError(e, getRealStackTrace(asyncError)); | 274 handleError(e, asyncError.stackTrace); |
275 }) | 275 }) |
276 // Explicitly exit on success to ensure that any dangling dart:io handles | 276 // Explicitly exit on success to ensure that any dangling dart:io handles |
277 // don't cause the process to never terminate. | 277 // don't cause the process to never terminate. |
278 .then((_) => exit(0)); | 278 .then((_) => exit(0)); |
279 } | 279 } |
280 | 280 |
281 /// Override this to perform the specific command. Return a future that | 281 /// Override this to perform the specific command. Return a future that |
282 /// completes when the command is done or fails if the command fails. If the | 282 /// completes when the command is done or fails if the command fails. If the |
283 /// command is synchronous, it may return `null`. | 283 /// command is synchronous, it may return `null`. |
284 Future onRun(); | 284 Future onRun(); |
(...skipping 20 matching lines...) Expand all Loading... |
305 if (exception is HttpException || exception is HttpParserException || | 305 if (exception is HttpException || exception is HttpParserException || |
306 exception is SocketIOException || exception is PubHttpException) { | 306 exception is SocketIOException || exception is PubHttpException) { |
307 return exit_codes.UNAVAILABLE; | 307 return exit_codes.UNAVAILABLE; |
308 } else if (exception is FormatException) { | 308 } else if (exception is FormatException) { |
309 return exit_codes.DATA; | 309 return exit_codes.DATA; |
310 } else { | 310 } else { |
311 return 1; | 311 return 1; |
312 } | 312 } |
313 } | 313 } |
314 } | 314 } |
OLD | NEW |