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'; |
| 10 import 'dart:math'; |
| 11 |
9 import '../../pkg/args/lib/args.dart'; | 12 import '../../pkg/args/lib/args.dart'; |
10 import '../../pkg/path/lib/path.dart' as path; | 13 import '../../pkg/path/lib/path.dart' as path; |
11 import 'dart:io'; | 14 |
12 import 'dart:math'; | |
13 import 'http.dart'; | |
14 import 'io.dart'; | |
15 import 'command_help.dart'; | 15 import 'command_help.dart'; |
16 import 'command_install.dart'; | 16 import 'command_install.dart'; |
17 import 'command_lish.dart'; | 17 import 'command_lish.dart'; |
18 import 'command_update.dart'; | 18 import 'command_update.dart'; |
19 import 'command_uploader.dart'; | 19 import 'command_uploader.dart'; |
20 import 'command_version.dart'; | 20 import 'command_version.dart'; |
21 import 'entrypoint.dart'; | 21 import 'entrypoint.dart'; |
22 import 'exit_codes.dart' as exit_codes; | 22 import 'exit_codes.dart' as exit_codes; |
| 23 import 'http.dart'; |
| 24 import 'io.dart'; |
23 import 'log.dart' as log; | 25 import 'log.dart' as log; |
24 import 'package.dart'; | 26 import 'package.dart'; |
25 import 'pubspec.dart'; | 27 import 'pubspec.dart'; |
26 import 'sdk.dart' as sdk; | 28 import 'sdk.dart' as sdk; |
27 import 'source.dart'; | 29 import 'source.dart'; |
28 import 'source_registry.dart'; | 30 import 'source_registry.dart'; |
29 import 'system_cache.dart'; | 31 import 'system_cache.dart'; |
30 import 'utils.dart'; | 32 import 'utils.dart'; |
31 import 'version.dart'; | 33 import 'version.dart'; |
32 | 34 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 break; | 111 break; |
110 } | 112 } |
111 | 113 |
112 SecureSocket.initialize(database: relativeToPub('resource/certs')); | 114 SecureSocket.initialize(database: relativeToPub('resource/certs')); |
113 | 115 |
114 var cacheDir; | 116 var cacheDir; |
115 if (Platform.environment.containsKey('PUB_CACHE')) { | 117 if (Platform.environment.containsKey('PUB_CACHE')) { |
116 cacheDir = Platform.environment['PUB_CACHE']; | 118 cacheDir = Platform.environment['PUB_CACHE']; |
117 } else if (Platform.operatingSystem == 'windows') { | 119 } else if (Platform.operatingSystem == 'windows') { |
118 var appData = Platform.environment['APPDATA']; | 120 var appData = Platform.environment['APPDATA']; |
119 cacheDir = join(appData, 'Pub', 'Cache'); | 121 cacheDir = path.join(appData, 'Pub', 'Cache'); |
120 } else { | 122 } else { |
121 cacheDir = '${Platform.environment['HOME']}/.pub-cache'; | 123 cacheDir = '${Platform.environment['HOME']}/.pub-cache'; |
122 } | 124 } |
123 | 125 |
124 validatePlatform().then((_) { | 126 validatePlatform().then((_) { |
125 var cache = new SystemCache.withSources(cacheDir); | 127 var cache = new SystemCache.withSources(cacheDir); |
126 | 128 |
127 // Select the command. | 129 // Select the command. |
128 var command = pubCommands[globalOptions.rest[0]]; | 130 var command = pubCommands[globalOptions.rest[0]]; |
129 if (command == null) { | 131 if (command == null) { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 if (exception is HttpException || exception is HttpParserException || | 318 if (exception is HttpException || exception is HttpParserException || |
317 exception is SocketIOException || exception is PubHttpException) { | 319 exception is SocketIOException || exception is PubHttpException) { |
318 return exit_codes.UNAVAILABLE; | 320 return exit_codes.UNAVAILABLE; |
319 } else if (exception is FormatException) { | 321 } else if (exception is FormatException) { |
320 return exit_codes.DATA; | 322 return exit_codes.DATA; |
321 } else { | 323 } else { |
322 return 1; | 324 return 1; |
323 } | 325 } |
324 } | 326 } |
325 } | 327 } |
OLD | NEW |