| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 io.ProcessResult result; | 48 io.ProcessResult result; |
| 49 try { | 49 try { |
| 50 result = io.Process.runSync( | 50 result = io.Process.runSync( |
| 51 executable, | 51 executable, |
| 52 [PUB_LIST_COMMAND], | 52 [PUB_LIST_COMMAND], |
| 53 workingDirectory: folder.path); | 53 workingDirectory: folder.path); |
| 54 } on io.ProcessException catch (exception, stackTrace) { | 54 } on io.ProcessException catch (exception, stackTrace) { |
| 55 AnalysisEngine.instance.logger.logInformation( | 55 AnalysisEngine.instance.logger.logInformation( |
| 56 "Error running pub $PUB_LIST_COMMAND\n$exception\n$stackTrace"); | 56 "Error running pub $PUB_LIST_COMMAND\n$exception\n$stackTrace"); |
| 57 } | 57 } |
| 58 if (result.exitCode != 0) { | 58 if (result == null || result.exitCode != 0) { |
| 59 AnalysisEngine.instance.logger.logInformation( | 59 AnalysisEngine.instance.logger.logInformation( |
| 60 "pub $PUB_LIST_COMMAND failed: exit code ${result.exitCode}"); | 60 "pub $PUB_LIST_COMMAND failed: exit code ${result.exitCode}"); |
| 61 return _error(folder); | 61 return _error(folder); |
| 62 } | 62 } |
| 63 try { | 63 try { |
| 64 return parsePackageMap(result.stdout, folder); | 64 return parsePackageMap(result.stdout, folder); |
| 65 } catch (exception, stackTrace) { | 65 } catch (exception, stackTrace) { |
| 66 AnalysisEngine.instance.logger.logError( | 66 AnalysisEngine.instance.logger.logError( |
| 67 "Malformed output from pub $PUB_LIST_COMMAND\n$exception\n$stackTrace"
); | 67 "Malformed output from pub $PUB_LIST_COMMAND\n$exception\n$stackTrace"
); |
| 68 } | 68 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 */ | 127 */ |
| 128 PackageMapInfo _error(Folder folder) { | 128 PackageMapInfo _error(Folder folder) { |
| 129 // 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 |
| 130 // 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. |
| 131 // Unfortunately, "pub list-package-dirs" doesn't tell us dependencies when | 131 // Unfortunately, "pub list-package-dirs" doesn't tell us dependencies when |
| 132 // 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". |
| 133 List<String> dependencies = <String>[join(folder.path, PUBSPEC_LOCK_NAME)]; | 133 List<String> dependencies = <String>[join(folder.path, PUBSPEC_LOCK_NAME)]; |
| 134 return new PackageMapInfo(null, dependencies.toSet()); | 134 return new PackageMapInfo(null, dependencies.toSet()); |
| 135 } | 135 } |
| 136 } | 136 } |
| OLD | NEW |