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.global_packages; | 5 library pub.global_packages; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 278 |
279 return true; | 279 return true; |
280 } | 280 } |
281 | 281 |
282 /// Finds the active package with [name]. | 282 /// Finds the active package with [name]. |
283 /// | 283 /// |
284 /// Returns an [Entrypoint] loaded with the active package if found. | 284 /// Returns an [Entrypoint] loaded with the active package if found. |
285 Future<Entrypoint> find(String name) { | 285 Future<Entrypoint> find(String name) { |
286 // TODO(rnystrom): Use async/await here when on __ catch is supported. | 286 // TODO(rnystrom): Use async/await here when on __ catch is supported. |
287 // See: https://github.com/dart-lang/async_await/issues/27 | 287 // See: https://github.com/dart-lang/async_await/issues/27 |
288 return syncFuture(() { | 288 return new Future.sync(() { |
289 var lockFilePath = _getLockFilePath(name); | 289 var lockFilePath = _getLockFilePath(name); |
290 var lockFile; | 290 var lockFile; |
291 try { | 291 try { |
292 lockFile = new LockFile.load(lockFilePath, cache.sources); | 292 lockFile = new LockFile.load(lockFilePath, cache.sources); |
293 } on IOException catch (error) { | 293 } on IOException catch (error) { |
294 var oldLockFilePath = p.join(_directory, '$name.lock'); | 294 var oldLockFilePath = p.join(_directory, '$name.lock'); |
295 try { | 295 try { |
296 // TODO(nweiz): This looks for Dart 1.6's old lockfile location. | 296 // TODO(nweiz): This looks for Dart 1.6's old lockfile location. |
297 // Remove it when Dart 1.6 is old enough that we don't think anyone | 297 // Remove it when Dart 1.6 is old enough that we don't think anyone |
298 // will have these lockfiles anymore (issue 20703). | 298 // will have these lockfiles anymore (issue 20703). |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 continue; | 588 continue; |
589 } | 589 } |
590 | 590 |
591 if (match[1] == package) { | 591 if (match[1] == package) { |
592 log.fine("Deleting old binstub $file"); | 592 log.fine("Deleting old binstub $file"); |
593 deleteEntry(file); | 593 deleteEntry(file); |
594 } | 594 } |
595 } | 595 } |
596 } | 596 } |
597 } | 597 } |
OLD | NEW |