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

Unified Diff: lib/src/pubspec.dart

Issue 1556043006: Don't choke on dev transformers from path deps. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 4 years, 12 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 | test/transformer/gets_and_upgrades_a_package_with_a_dev_transformer_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/pubspec.dart
diff --git a/lib/src/pubspec.dart b/lib/src/pubspec.dart
index db55b4d5a41be5c1edfc6d0ad22b8ddc288a2466..b1aa3c7e576d444294bb6e83c44dbd2e11f221ad 100644
--- a/lib/src/pubspec.dart
+++ b/lib/src/pubspec.dart
@@ -190,11 +190,8 @@ class Pubspec {
});
var package = config.id.package;
- if (package != name &&
- !config.id.isBuiltInTransformer &&
- !dependencies.any((ref) => ref.name == package) &&
- !devDependencies.any((ref) => ref.name == package) &&
- !dependencyOverrides.any((ref) => ref.name == package)) {
+ if (package != name && !config.id.isBuiltInTransformer &&
+ !_hasDependency(package)) {
_error('"$package" is not a dependency.',
libraryNode.span);
}
@@ -207,6 +204,26 @@ class Pubspec {
}
List<Set<TransformerConfig>> _transformers;
+ /// Returns whether this pubspec has any kind of dependency on [package].
+ ///
+ /// This explicitly avoids calling [_parseDependencies] because parsing dev
+ /// dependencies can fail for a hosted package's pubspec (e.g. if that package
+ /// has a relative path dev dependency).
+ bool _hasDependency(String package) {
+ return [
+ 'dependencies', 'dev_dependencies', 'dependency_overrides'
+ ].any((field) {
+ var map = fields[field];
+ if (map == null) return false;
+
+ if (map is! Map) {
+ _error('"$field" field must be a map.', fields.nodes[field].span);
+ }
+
+ return map.containsKey(package);
+ });
+ }
+
/// The environment-related metadata.
PubspecEnvironment get environment {
if (_environment != null) return _environment;
@@ -496,15 +513,13 @@ class Pubspec {
}
// Let the source validate the description.
- var ref = _wrapFormatException('description', descriptionNode.span, () {
var pubspecPath;
Bob Nystrom 2016/01/04 23:46:44 Fix the indentation.
nweiz 2016/01/05 01:57:13 Oops, this whole change shouldn't have made it in.
if (_location != null && _isFileUri(_location)) {
pubspecPath = path.fromUri(_location);
}
- return _sources[sourceName].parseRef(name, descriptionNode.value,
+ var ref = _sources[sourceName].parseRef(name, descriptionNode.value,
containingPath: pubspecPath);
- });
dependencies.add(ref.withConstraint(versionConstraint));
});
« no previous file with comments | « no previous file | test/transformer/gets_and_upgrades_a_package_with_a_dev_transformer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698