| 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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 if (result != null) { | 459 if (result != null) { |
| 460 var packages = new Map.fromIterable(result.packages, | 460 var packages = new Map.fromIterable(result.packages, |
| 461 key: (id) => id.name, | 461 key: (id) => id.name, |
| 462 value: (id) { | 462 value: (id) { |
| 463 if (id.name == root.name) return root; | 463 if (id.name == root.name) return root; |
| 464 | 464 |
| 465 return new Package(result.pubspecs[id.name], | 465 return new Package(result.pubspecs[id.name], |
| 466 cache.sources[id.source].getDirectory(id)); | 466 cache.sources[id.source].getDirectory(id)); |
| 467 }); | 467 }); |
| 468 | 468 |
| 469 return new PackageGraph(this, new LockFile(result.packages), packages); | 469 return new PackageGraph( |
| 470 this, |
| 471 new LockFile(result.packages, cache.sources), |
| 472 packages); |
| 470 } | 473 } |
| 471 | 474 |
| 472 await ensureLockFileIsUpToDate(); | 475 await ensureLockFileIsUpToDate(); |
| 473 var packages = new Map.fromIterable(lockFile.packages.values, | 476 var packages = new Map.fromIterable(lockFile.packages.values, |
| 474 key: (id) => id.name, | 477 key: (id) => id.name, |
| 475 value: (id) { | 478 value: (id) { |
| 476 var dir = cache.sources[id.source].getDirectory(id); | 479 var dir = cache.sources[id.source].getDirectory(id); |
| 477 return new Package.load(id.name, dir, cache.sources); | 480 return new Package.load(id.name, dir, cache.sources); |
| 478 }); | 481 }); |
| 479 packages[root.name] = root; | 482 packages[root.name] = root; |
| 480 return new PackageGraph(this, lockFile, packages); | 483 return new PackageGraph(this, lockFile, packages); |
| 481 }, fine: true); | 484 }, fine: true); |
| 482 | 485 |
| 483 _packageGraph = graph; | 486 _packageGraph = graph; |
| 484 return graph; | 487 return graph; |
| 485 } | 488 } |
| 486 | 489 |
| 487 /// Saves a list of concrete package versions to the `pubspec.lock` file. | 490 /// Saves a list of concrete package versions to the `pubspec.lock` file. |
| 488 void _saveLockFile(List<PackageId> packageIds) { | 491 void _saveLockFile(List<PackageId> packageIds) { |
| 489 _lockFile = new LockFile(packageIds); | 492 _lockFile = new LockFile(packageIds, cache.sources); |
| 490 var lockFilePath = root.path('pubspec.lock'); | 493 var lockFilePath = root.path('pubspec.lock'); |
| 491 writeTextFile(lockFilePath, _lockFile.serialize(root.dir, cache.sources)); | 494 writeTextFile(lockFilePath, _lockFile.serialize(root.dir)); |
| 492 } | 495 } |
| 493 | 496 |
| 494 /// Creates a self-referential symlink in the `packages` directory that allows | 497 /// Creates a self-referential symlink in the `packages` directory that allows |
| 495 /// a package to import its own files using `package:`. | 498 /// a package to import its own files using `package:`. |
| 496 void _linkSelf() { | 499 void _linkSelf() { |
| 497 var linkPath = path.join(packagesDir, root.name); | 500 var linkPath = path.join(packagesDir, root.name); |
| 498 // Create the symlink if it doesn't exist. | 501 // Create the symlink if it doesn't exist. |
| 499 if (entryExists(linkPath)) return; | 502 if (entryExists(linkPath)) return; |
| 500 ensureDir(packagesDir); | 503 ensureDir(packagesDir); |
| 501 createPackageSymlink(root.name, root.dir, linkPath, | 504 createPackageSymlink(root.name, root.dir, linkPath, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 /// If [packageSymlinks] is true, creates a symlink to the "packages" | 551 /// If [packageSymlinks] is true, creates a symlink to the "packages" |
| 549 /// directory in [dir]. | 552 /// directory in [dir]. |
| 550 /// | 553 /// |
| 551 /// Otherwise, deletes a "packages" directories in [dir] if one exists. | 554 /// Otherwise, deletes a "packages" directories in [dir] if one exists. |
| 552 void _linkOrDeleteSecondaryPackageDir(String dir) { | 555 void _linkOrDeleteSecondaryPackageDir(String dir) { |
| 553 var symlink = path.join(dir, 'packages'); | 556 var symlink = path.join(dir, 'packages'); |
| 554 if (entryExists(symlink)) deleteEntry(symlink); | 557 if (entryExists(symlink)) deleteEntry(symlink); |
| 555 if (_packageSymlinks) createSymlink(packagesDir, symlink, relative: true); | 558 if (_packageSymlinks) createSymlink(packagesDir, symlink, relative: true); |
| 556 } | 559 } |
| 557 } | 560 } |
| OLD | NEW |