| 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 path_source; | 5 library path_source; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:pathos/path.dart' as path; | 10 import 'package:pathos/path.dart' as path; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 | 41 |
| 42 Future<bool> install(PackageId id, String destination) { | 42 Future<bool> install(PackageId id, String destination) { |
| 43 return defer(() { | 43 return defer(() { |
| 44 try { | 44 try { |
| 45 _validatePath(id.name, id.description); | 45 _validatePath(id.name, id.description); |
| 46 } on FormatException catch(err) { | 46 } on FormatException catch(err) { |
| 47 return false; | 47 return false; |
| 48 } | 48 } |
| 49 | 49 |
| 50 return createPackageSymlink(id.name, id.description["path"], destination, | 50 createPackageSymlink(id.name, id.description["path"], destination, |
| 51 relative: id.description["relative"]); | 51 relative: id.description["relative"]); |
| 52 }).then((_) => true); | 52 return true; |
| 53 }); |
| 53 } | 54 } |
| 54 | 55 |
| 55 /// Parses a path dependency. This takes in a path string and returns a map. | 56 /// Parses a path dependency. This takes in a path string and returns a map. |
| 56 /// The "path" key will be the original path but resolved relative to the | 57 /// The "path" key will be the original path but resolved relative to the |
| 57 /// containing path. The "relative" key will be `true` if the original path | 58 /// containing path. The "relative" key will be `true` if the original path |
| 58 /// was relative. | 59 /// was relative. |
| 59 /// | 60 /// |
| 60 /// A path coming from a pubspec is a simple string. From a lock file, it's | 61 /// A path coming from a pubspec is a simple string. From a lock file, it's |
| 61 /// an expanded {"path": ..., "relative": ...} map. | 62 /// an expanded {"path": ..., "relative": ...} map. |
| 62 dynamic parseDescription(String containingPath, description, | 63 dynamic parseDescription(String containingPath, description, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 111 |
| 111 if (fileExists(dir)) { | 112 if (fileExists(dir)) { |
| 112 throw new FormatException( | 113 throw new FormatException( |
| 113 "Path dependency for package '$name' must refer to a " | 114 "Path dependency for package '$name' must refer to a " |
| 114 "directory, not a file. Was '$dir'."); | 115 "directory, not a file. Was '$dir'."); |
| 115 } | 116 } |
| 116 | 117 |
| 117 throw new FormatException("Could not find package '$name' at '$dir'."); | 118 throw new FormatException("Could not find package '$name' at '$dir'."); |
| 118 } | 119 } |
| 119 } | 120 } |
| OLD | NEW |