Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(678)

Unified Diff: sdk/lib/_internal/pub/lib/src/global_packages.dart

Issue 868463003: Regenerate pub's sources and remove workarounds for fixed issues. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/executable.dart ('k') | sdk/lib/_internal/pub/lib/src/source/hosted.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/global_packages.dart
diff --git a/sdk/lib/_internal/pub/lib/src/global_packages.dart b/sdk/lib/_internal/pub/lib/src/global_packages.dart
index 2a20acaf1e4573148c9a5733ac0b83393ab1d673..6ce58a775a445b9b8edc05e1fb1e796c16a2e829 100644
--- a/sdk/lib/_internal/pub/lib/src/global_packages.dart
+++ b/sdk/lib/_internal/pub/lib/src/global_packages.dart
@@ -282,52 +282,46 @@ class GlobalPackages {
/// Finds the active package with [name].
///
/// Returns an [Entrypoint] loaded with the active package if found.
- Future<Entrypoint> find(String name) {
- // TODO(rnystrom): Use async/await here when on __ catch is supported.
- // See: https://github.com/dart-lang/async_await/issues/27
- return new Future.sync(() {
- var lockFilePath = _getLockFilePath(name);
- var lockFile;
+ Future<Entrypoint> find(String name) async {
+ var lockFilePath = _getLockFilePath(name);
+ var lockFile;
+ try {
+ lockFile = new LockFile.load(lockFilePath, cache.sources);
+ } on IOException catch (error) {
+ var oldLockFilePath = p.join(_directory, '$name.lock');
try {
- lockFile = new LockFile.load(lockFilePath, cache.sources);
+ // TODO(nweiz): This looks for Dart 1.6's old lockfile location.
+ // Remove it when Dart 1.6 is old enough that we don't think anyone
+ // will have these lockfiles anymore (issue 20703).
+ lockFile = new LockFile.load(oldLockFilePath, cache.sources);
} on IOException catch (error) {
- var oldLockFilePath = p.join(_directory, '$name.lock');
- try {
- // TODO(nweiz): This looks for Dart 1.6's old lockfile location.
- // Remove it when Dart 1.6 is old enough that we don't think anyone
- // will have these lockfiles anymore (issue 20703).
- lockFile = new LockFile.load(oldLockFilePath, cache.sources);
- } on IOException catch (error) {
- // If we couldn't read the lock file, it's not activated.
- dataError("No active package ${log.bold(name)}.");
- }
-
- // Move the old lockfile to its new location.
- ensureDir(p.dirname(lockFilePath));
- new File(oldLockFilePath).renameSync(lockFilePath);
+ // If we couldn't read the lock file, it's not activated.
+ dataError("No active package ${log.bold(name)}.");
}
- // Load the package from the cache.
- var id = lockFile.packages[name];
- lockFile.packages.remove(name);
-
- var source = cache.sources[id.source];
- if (source is CachedSource) {
- // For cached sources, the package itself is in the cache and the
- // lockfile is the one we just loaded.
- return cache.sources[id.source].getDirectory(id)
- .then((dir) => new Package.load(name, dir, cache.sources))
- .then((package) {
- return new Entrypoint.inMemory(package, lockFile, cache);
- });
- }
+ // Move the old lockfile to its new location.
+ ensureDir(p.dirname(lockFilePath));
+ new File(oldLockFilePath).renameSync(lockFilePath);
+ }
- // For uncached sources (i.e. path), the ID just points to the real
- // directory for the package.
- assert(id.source == "path");
- return new Entrypoint(PathSource.pathFromDescription(id.description),
- cache);
- });
+ // Load the package from the cache.
+ var id = lockFile.packages[name];
+ lockFile.packages.remove(name);
+
+ var source = cache.sources[id.source];
+ if (source is CachedSource) {
+ // For cached sources, the package itself is in the cache and the
+ // lockfile is the one we just loaded.
+ var dir = await cache.sources[id.source].getDirectory(id);
+ var package = new Package.load(name, dir, cache.sources);
+ return new Entrypoint.inMemory(package, lockFile, cache);
+ }
+
+ // For uncached sources (i.e. path), the ID just points to the real
+ // directory for the package.
+ assert(id.source == "path");
+ return new Entrypoint(PathSource.pathFromDescription(id.description),
+ cache);
}
/// Runs [package]'s [executable] with [args].
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/executable.dart ('k') | sdk/lib/_internal/pub/lib/src/source/hosted.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698