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 pub.command.list; | 5 library pub.command.list; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import '../ascii_tree.dart' as tree; | 9 import '../ascii_tree.dart' as tree; |
10 import '../command.dart'; | 10 import '../command.dart'; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 // package. | 148 // package. |
149 var toWalk = new Queue<Pair<Package, Map>>(); | 149 var toWalk = new Queue<Pair<Package, Map>>(); |
150 var visited = new Set<String>.from([entrypoint.root.name]); | 150 var visited = new Set<String>.from([entrypoint.root.name]); |
151 | 151 |
152 // Start with the root dependencies. | 152 // Start with the root dependencies. |
153 var packageTree = {}; | 153 var packageTree = {}; |
154 var immediateDependencies = entrypoint.root.immediateDependencies.toSet(); | 154 var immediateDependencies = entrypoint.root.immediateDependencies.toSet(); |
155 if (!_includeDev) { | 155 if (!_includeDev) { |
156 immediateDependencies.removeAll(entrypoint.root.devDependencies); | 156 immediateDependencies.removeAll(entrypoint.root.devDependencies); |
157 } | 157 } |
158 for (var dep in immediateDependenciesr) { | 158 for (var dep in immediateDependencies) { |
159 toWalk.add(new Pair(_getPackage(dep.name), packageTree)); | 159 toWalk.add(new Pair(_getPackage(dep.name), packageTree)); |
160 } | 160 } |
161 | 161 |
162 // Do a breadth-first walk to the dependency graph. | 162 // Do a breadth-first walk to the dependency graph. |
163 while (toWalk.isNotEmpty) { | 163 while (toWalk.isNotEmpty) { |
164 var pair = toWalk.removeFirst(); | 164 var pair = toWalk.removeFirst(); |
165 var package = pair.first; | 165 var package = pair.first; |
166 var map = pair.last; | 166 var map = pair.last; |
167 | 167 |
168 if (visited.contains(package.name)) { | 168 if (visited.contains(package.name)) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 /// It's very unlikely that the lockfile won't be up-to-date with the pubspec, | 218 /// It's very unlikely that the lockfile won't be up-to-date with the pubspec, |
219 /// but it's possible, since [Entrypoint.assertUpToDate]'s modification time | 219 /// but it's possible, since [Entrypoint.assertUpToDate]'s modification time |
220 /// check can return a false negative. This fails gracefully if that happens. | 220 /// check can return a false negative. This fails gracefully if that happens. |
221 Package _getPackage(String name) { | 221 Package _getPackage(String name) { |
222 var package = entrypoint.packageGraph.packages[name]; | 222 var package = entrypoint.packageGraph.packages[name]; |
223 if (package != null) return package; | 223 if (package != null) return package; |
224 dataError('The pubspec.yaml file has changed since the pubspec.lock file ' | 224 dataError('The pubspec.yaml file has changed since the pubspec.lock file ' |
225 'was generated, please run "pub get" again.'); | 225 'was generated, please run "pub get" again.'); |
226 } | 226 } |
227 } | 227 } |
OLD | NEW |