| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.source.path; | 5 library pub.source.path; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 } | 50 } |
| 51 | 51 |
| 52 Future get(PackageId id, String symlink) { | 52 Future get(PackageId id, String symlink) { |
| 53 return new Future.sync(() { | 53 return new Future.sync(() { |
| 54 var dir = _validatePath(id.name, id.description); | 54 var dir = _validatePath(id.name, id.description); |
| 55 createPackageSymlink(id.name, dir, symlink, | 55 createPackageSymlink(id.name, dir, symlink, |
| 56 relative: id.description["relative"]); | 56 relative: id.description["relative"]); |
| 57 }); | 57 }); |
| 58 } | 58 } |
| 59 | 59 |
| 60 Future<String> getDirectory(PackageId id) => | 60 String getDirectory(PackageId id) => _validatePath(id.name, id.description); |
| 61 newFuture(() => _validatePath(id.name, id.description)); | |
| 62 | 61 |
| 63 /// Parses a path dependency. | 62 /// Parses a path dependency. |
| 64 /// | 63 /// |
| 65 /// This takes in a path string and returns a map. The "path" key will be the | 64 /// This takes in a path string and returns a map. The "path" key will be the |
| 66 /// original path but resolved relative to the containing path. The | 65 /// original path but resolved relative to the containing path. The |
| 67 /// "relative" key will be `true` if the original path was relative. | 66 /// "relative" key will be `true` if the original path was relative. |
| 68 /// | 67 /// |
| 69 /// A path coming from a pubspec is a simple string. From a lock file, it's | 68 /// A path coming from a pubspec is a simple string. From a lock file, it's |
| 70 /// an expanded {"path": ..., "relative": ...} map. | 69 /// an expanded {"path": ..., "relative": ...} map. |
| 71 dynamic parseDescription(String containingPath, description, | 70 dynamic parseDescription(String containingPath, description, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 150 |
| 152 if (fileExists(dir)) { | 151 if (fileExists(dir)) { |
| 153 fail('Path dependency for package $name must refer to a directory, ' | 152 fail('Path dependency for package $name must refer to a directory, ' |
| 154 'not a file. Was "$dir".'); | 153 'not a file. Was "$dir".'); |
| 155 } | 154 } |
| 156 | 155 |
| 157 throw new PackageNotFoundException( | 156 throw new PackageNotFoundException( |
| 158 'Could not find package $name at "$dir".'); | 157 'Could not find package $name at "$dir".'); |
| 159 } | 158 } |
| 160 } | 159 } |
| OLD | NEW |