Chromium Code Reviews| Index: sdk/lib/_internal/pub/lib/src/source/path.dart |
| diff --git a/sdk/lib/_internal/pub/lib/src/source/path.dart b/sdk/lib/_internal/pub/lib/src/source/path.dart |
| index 7e43dfbc7f3bdab9e7444ad6345fbc7bc4786429..6f83c5be76a247e1188ea76ac451e3ddaad6a4d4 100644 |
| --- a/sdk/lib/_internal/pub/lib/src/source/path.dart |
| +++ b/sdk/lib/_internal/pub/lib/src/source/path.dart |
| @@ -6,7 +6,7 @@ library pub.source.path; |
| import 'dart:async'; |
| -import 'package:path/path.dart' as path; |
| +import 'package:path/path.dart' as p; |
| import '../exceptions.dart'; |
| import '../io.dart'; |
| @@ -17,6 +17,17 @@ import '../utils.dart'; |
| /// A package [Source] that gets packages from a given local file path. |
| class PathSource extends Source { |
| + /// Returns a valid description for a reference to a package at [path]. |
| + static describePath(String path) { |
| + return { |
| + "path": path, |
| + "relative": p.isRelative(path) |
| + }; |
| + } |
| + |
| + /// Given a valid path reference description, returns the actual path. |
| + static String pathFromDescription(description) => description["path"]; |
|
nweiz
2014/07/31 20:01:54
If this path is relative, won't it be relative to
Bob Nystrom
2014/08/04 23:41:51
GlobalPackages ensures that the path is already ma
|
| + |
| final name = 'path'; |
| Future<Pubspec> doDescribe(PackageId id) { |
| @@ -79,14 +90,14 @@ class PathSource extends Source { |
| // Resolve the path relative to the containing file path, and remember |
| // whether the original path was relative or absolute. |
| - bool isRelative = path.isRelative(description); |
| - if (path.isRelative(description)) { |
| + var isRelative = p.isRelative(description); |
| + if (p.isRelative(description)) { |
| // Can't handle relative paths coming from pubspecs that are not on the |
| // local file system. |
| assert(containingPath != null); |
| - description = path.normalize( |
| - path.join(path.dirname(containingPath), description)); |
| + description = p.normalize( |
| + p.join(p.dirname(containingPath), description)); |
| } |
| return { |
| @@ -102,7 +113,7 @@ class PathSource extends Source { |
| dynamic serializeDescription(String containingPath, description) { |
| if (description["relative"]) { |
| return { |
| - "path": path.relative(description['path'], from: containingPath), |
| + "path": p.relative(description['path'], from: containingPath), |
| "relative": true |
| }; |
| } |
| @@ -113,7 +124,7 @@ class PathSource extends Source { |
| String formatDescription(String containingPath, description) { |
| var sourcePath = description["path"]; |
| if (description["relative"]) { |
| - sourcePath = path.relative(description['path'], from: containingPath); |
| + sourcePath = p.relative(description['path'], from: containingPath); |
| } |
| return sourcePath; |