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

Unified Diff: sdk/lib/_internal/pub/lib/src/source/path.dart

Issue 34803006: Make pubspec.lock keep relative path if it is originally specified as relative in pubspec.yaml (iss… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Improve code according to the code review comments Created 7 years, 1 month 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
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 9af0fd11e2320dd384e522050023134efde49613..2dfe1520c6b0ae9164ee035a3877175c1eca1338 100644
--- a/sdk/lib/_internal/pub/lib/src/source/path.dart
+++ b/sdk/lib/_internal/pub/lib/src/source/path.dart
@@ -90,7 +90,8 @@ class PathSource extends Source {
// local file system.
assert(containingPath != null);
- description = path.join(path.dirname(containingPath), description);
+ description = path.normalize(
+ path.join(path.dirname(containingPath), description));
}
return {
@@ -99,6 +100,19 @@ class PathSource extends Source {
};
}
+ /// Serializes path dependency's [description]. For the descriptions where
+ /// `relative` attribute is `true`, tries to make `path` relative to the
+ /// specified [containingPath].
+ dynamic serializeDescription(String containingPath, description) {
+ if (description["relative"]) {
+ return {
+ "path": path.relative(description['path'], from: containingPath),
+ "relative": true
+ };
+ }
+ return description;
+ }
+
/// Ensures that [description] is a valid path description and returns a
/// normalized path to the package.
///
@@ -106,7 +120,7 @@ class PathSource extends Source {
/// existing directory. Throws an [ApplicationException] if the path is
/// invalid.
String _validatePath(String name, description) {
- var dir = path.normalize(description["path"]);
+ var dir = description["path"];
if (dirExists(dir)) return dir;
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/source.dart ('k') | sdk/lib/_internal/pub/test/get/path/relative_path_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698