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

Unified Diff: lib/src/utils.dart

Issue 1013363002: locating runtime files automatically (fixes #96) (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 months 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
« no previous file with comments | « lib/src/testing.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/utils.dart
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index c276858f9de752f8232769d639399bd96c04691e..7fc38a0d1beabdd58a28ad67efc4feeffea8e722 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -298,4 +298,20 @@ String computeHash(String contents) {
return CryptoUtils.bytesToHex((new MD5()..add(contents.codeUnits)).close());
}
-String resourceOutputPath(Uri resourceUri) => resourceUri.path;
+String resourceOutputPath(Uri resourceUri) {
+ if (resourceUri.scheme == 'package') return resourceUri.path;
+
+ // Only support file:/// urls for resources in the dev_compiler package
+ if (resourceUri.scheme != 'file') return null;
+ var segments = resourceUri.pathSegments;
+ var len = segments.length;
+ if (segments.length < 4 ||
+ segments[len - 2] != 'runtime' ||
+ segments[len - 3] != 'lib' ||
+ // If loaded from sources this will be exactly dev_compiler, otherwise it
+ // can be the name in the pub cache (typically dev_compiler-version).
+ !segments[len - 4].startsWith('dev_compiler')) {
+ return null;
+ }
+ return path.joinAll(['dev_compiler']..addAll(segments.skip(len - 2)));
+}
« no previous file with comments | « lib/src/testing.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698