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

Unified Diff: utils/pub/pubspec.dart

Issue 12433014: Dev dependencies. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: List all colliding package names. Created 7 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 | utils/pub/sdk_source.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/pubspec.dart
diff --git a/utils/pub/pubspec.dart b/utils/pub/pubspec.dart
index 81678afc0b039f234c7c1c65bc88141e2b3b54cf..f2d34a2ef31edd561f1ec58775e080a48eff7be8 100644
--- a/utils/pub/pubspec.dart
+++ b/utils/pub/pubspec.dart
@@ -25,6 +25,9 @@ class Pubspec {
/// The packages this package depends on.
final List<PackageRef> dependencies;
+ /// The packages this package depends on when it is the root package.
+ final List<PackageRef> devDependencies;
+
/// The environment-related metadata.
final PubspecEnvironment environment;
@@ -55,14 +58,15 @@ class Pubspec {
}
}
- Pubspec(this.name, this.version, this.dependencies, this.environment,
- [Map<String, Object> fields])
+ Pubspec(this.name, this.version, this.dependencies, this.devDependencies,
+ this.environment, [Map<String, Object> fields])
: this.fields = fields == null ? {} : fields;
Pubspec.empty()
: name = null,
version = Version.none,
dependencies = <PackageRef>[],
+ devDependencies = <PackageRef>[],
environment = new PubspecEnvironment(),
fields = {};
@@ -105,6 +109,42 @@ class Pubspec {
var dependencies = _parseDependencies(filePath, sources,
parsedPubspec['dependencies']);
+ var devDependencies = _parseDependencies(filePath, sources,
+ parsedPubspec['dev_dependencies']);
+
+ // Make sure the same package doesn't appear as both a regular and dev
+ // dependency.
+ var dependencyNames = dependencies.map((dep) => dep.name).toSet();
+ var collisions = dependencyNames.intersection(
+ devDependencies.map((dep) => dep.name).toSet());
+
+ if (!collisions.isEmpty) {
+ var packageNames;
+ if (collisions.length == 1) {
+ packageNames = 'Package "${collisions.first}"';
+ } else {
+ var names = collisions.toList();
+ names.sort();
+ var buffer = new StringBuffer();
+ buffer.write("Packages ");
+ for (var i = 0; i < names.length; i++) {
+ buffer.write('"');
+ buffer.write(names[i]);
+ buffer.write('"');
+ if (i == names.length - 2) {
+ buffer.write(", ");
+ } else if (i == names.length - 1) {
+ buffer.write(", and ");
+ }
+ }
+
+ packageNames = buffer.toString();
+ }
+ throw new FormatException(
+ '$packageNames cannot appear in both "dependencies" and '
+ '"dev_dependencies".');
+ }
+
var environmentYaml = parsedPubspec['environment'];
var sdkConstraint = VersionConstraint.any;
if (environmentYaml != null) {
@@ -169,7 +209,8 @@ class Pubspec {
}
}
- return new Pubspec(name, version, dependencies, environment, parsedPubspec);
+ return new Pubspec(name, version, dependencies, devDependencies,
+ environment, parsedPubspec);
}
}
« no previous file with comments | « no previous file | utils/pub/sdk_source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698