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 library pub.entrypoint; | 5 library pub.entrypoint; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:path/path.dart' as path; | 9 import 'package:path/path.dart' as path; |
10 import 'package:barback/barback.dart'; | 10 import 'package:barback/barback.dart'; |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 /// | 463 /// |
464 /// If [result] is passed, this loads the graph from it without re-parsing the | 464 /// If [result] is passed, this loads the graph from it without re-parsing the |
465 /// lockfile or any pubspecs. Otherwise, before loading, this makes sure the | 465 /// lockfile or any pubspecs. Otherwise, before loading, this makes sure the |
466 /// lockfile and dependencies are installed and up to date. | 466 /// lockfile and dependencies are installed and up to date. |
467 Future<PackageGraph> loadPackageGraph([SolveResult result]) async { | 467 Future<PackageGraph> loadPackageGraph([SolveResult result]) async { |
468 if (_packageGraph != null) return _packageGraph; | 468 if (_packageGraph != null) return _packageGraph; |
469 | 469 |
470 var graph = await log.progress("Loading package graph", () async { | 470 var graph = await log.progress("Loading package graph", () async { |
471 if (result != null) { | 471 if (result != null) { |
472 var packages = await Future.wait(result.packages.map((id) async { | 472 var packages = await Future.wait(result.packages.map((id) async { |
| 473 if (id.name == root.name) return root; |
| 474 |
473 var dir = await cache.sources[id.source].getDirectory(id); | 475 var dir = await cache.sources[id.source].getDirectory(id); |
474 return new Package(result.pubspecs[id.name], dir); | 476 return new Package(result.pubspecs[id.name], dir); |
475 })); | 477 })); |
476 | 478 |
477 return new PackageGraph(this, new LockFile(result.packages), | 479 return new PackageGraph(this, new LockFile(result.packages), |
478 new Map.fromIterable(packages, key: (package) => package.name)); | 480 new Map.fromIterable(packages, key: (package) => package.name)); |
479 } | 481 } |
480 | 482 |
481 await ensureLockFileIsUpToDate(); | 483 await ensureLockFileIsUpToDate(); |
482 var packages = await Future.wait(lockFile.packages.values.map((id) async { | 484 var packages = await Future.wait(lockFile.packages.values.map((id) async { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 /// If [packageSymlinks] is true, creates a symlink to the "packages" | 560 /// If [packageSymlinks] is true, creates a symlink to the "packages" |
559 /// directory in [dir]. | 561 /// directory in [dir]. |
560 /// | 562 /// |
561 /// Otherwise, deletes a "packages" directories in [dir] if one exists. | 563 /// Otherwise, deletes a "packages" directories in [dir] if one exists. |
562 void _linkOrDeleteSecondaryPackageDir(String dir) { | 564 void _linkOrDeleteSecondaryPackageDir(String dir) { |
563 var symlink = path.join(dir, 'packages'); | 565 var symlink = path.join(dir, 'packages'); |
564 if (entryExists(symlink)) deleteEntry(symlink); | 566 if (entryExists(symlink)) deleteEntry(symlink); |
565 if (_packageSymlinks) createSymlink(packagesDir, symlink, relative: true); | 567 if (_packageSymlinks) createSymlink(packagesDir, symlink, relative: true); |
566 } | 568 } |
567 } | 569 } |
OLD | NEW |