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

Unified Diff: lib/src/utils.dart

Issue 1018043005: Allow dev-compiler folder to have a different name, instead check the pubspec (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 | « no previous file | no next file » | 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 dd62656ddfa875dfc0f7bd617775b75237a0ab04..99902ada67a35ab67c300e29b33056ad9743450a 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -24,6 +24,7 @@ import 'package:analyzer/src/generated/element.dart';
import 'package:analyzer/analyzer.dart' show parseDirectives;
import 'package:crypto/crypto.dart' show CryptoUtils, MD5;
import 'package:source_span/source_span.dart';
+import 'package:yaml/yaml.dart';
import 'js/keywords.dart';
@@ -316,15 +317,18 @@ String resourceOutputPath(Uri resourceUri, Uri entryUri) {
// further inside the folder where the entrypoint is located, otherwise we
// assume this is a runtime resource from the dev_compiler.
if (!relativePath.startsWith('..')) return relativePath;
- 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)));
+
+ // Expect the code to live under lib/runtime/ in the dev_compiler's folder.
+ var filename = path.basename(filepath);
+ var dir = path.dirname(filepath);
+ if (path.basename(dir) != 'runtime') return null;
+ dir = path.dirname(dir);
+ if (path.basename(dir) != 'lib') return null;
+ dir = path.dirname(dir);
+ var pubspec =
+ loadYaml(new File(path.join(dir, 'pubspec.yaml')).readAsStringSync());
+
+ // Ensure this is loaded from the dev_compiler package.
+ if (pubspec['name'] != 'dev_compiler') return null;
+ return path.join('dev_compiler', 'runtime', filename);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698