| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library source.pub_package_map_provider; | 5 library source.pub_package_map_provider; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io' as io; | 9 import 'dart:io' as io; |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 @override | 42 @override |
| 43 PackageMapInfo computePackageMap(Folder folder) { | 43 PackageMapInfo computePackageMap(Folder folder) { |
| 44 // TODO(paulberry) make this asynchronous so that we can (a) do other | 44 // TODO(paulberry) make this asynchronous so that we can (a) do other |
| 45 // analysis while it's in progress, and (b) time out if it takes too long | 45 // analysis while it's in progress, and (b) time out if it takes too long |
| 46 // to respond. | 46 // to respond. |
| 47 String executable = sdk.pubExecutable.getAbsolutePath(); | 47 String executable = sdk.pubExecutable.getAbsolutePath(); |
| 48 io.ProcessResult result; | 48 io.ProcessResult result; |
| 49 try { | 49 try { |
| 50 result = io.Process.runSync( | 50 result = io.Process.runSync( |
| 51 executable, [PUB_LIST_COMMAND], workingDirectory: folder.path); | 51 executable, |
| 52 [PUB_LIST_COMMAND], |
| 53 workingDirectory: folder.path); |
| 52 } on io.ProcessException catch (exception, stackTrace) { | 54 } on io.ProcessException catch (exception, stackTrace) { |
| 53 AnalysisEngine.instance.logger.logInformation( | 55 AnalysisEngine.instance.logger.logInformation( |
| 54 "Error running pub $PUB_LIST_COMMAND\n$exception\n$stackTrace"); | 56 "Error running pub $PUB_LIST_COMMAND\n$exception\n$stackTrace"); |
| 55 } | 57 } |
| 56 if (result.exitCode != 0) { | 58 if (result.exitCode != 0) { |
| 57 AnalysisEngine.instance.logger.logInformation( | 59 AnalysisEngine.instance.logger.logInformation( |
| 58 "pub $PUB_LIST_COMMAND failed: exit code ${result.exitCode}"); | 60 "pub $PUB_LIST_COMMAND failed: exit code ${result.exitCode}"); |
| 59 return _error(folder); | 61 return _error(folder); |
| 60 } | 62 } |
| 61 try { | 63 try { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 * Create a PackageMapInfo object representing an error condition. | 126 * Create a PackageMapInfo object representing an error condition. |
| 125 */ | 127 */ |
| 126 PackageMapInfo _error(Folder folder) { | 128 PackageMapInfo _error(Folder folder) { |
| 127 // Even if an error occurs, we still need to know the dependencies, so that | 129 // Even if an error occurs, we still need to know the dependencies, so that |
| 128 // we'll know when to try running "pub list-package-dirs" again. | 130 // we'll know when to try running "pub list-package-dirs" again. |
| 129 // Unfortunately, "pub list-package-dirs" doesn't tell us dependencies when | 131 // Unfortunately, "pub list-package-dirs" doesn't tell us dependencies when |
| 130 // an error occurs, so just assume there is one dependency, "pubspec.lock". | 132 // an error occurs, so just assume there is one dependency, "pubspec.lock". |
| 131 List<String> dependencies = <String>[join(folder.path, PUBSPEC_LOCK_NAME)]; | 133 List<String> dependencies = <String>[join(folder.path, PUBSPEC_LOCK_NAME)]; |
| 132 return new PackageMapInfo(null, dependencies.toSet()); | 134 return new PackageMapInfo(null, dependencies.toSet()); |
| 133 } | 135 } |
| 134 } | 136 } |
| OLD | NEW |