Chromium Code Reviews| Index: utils/pub/pubspec.dart |
| diff --git a/utils/pub/pubspec.dart b/utils/pub/pubspec.dart |
| index 81678afc0b039f234c7c1c65bc88141e2b3b54cf..92cf29bbfe488f856fa0f92dcc3aa8e66057d59f 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,21 @@ 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) { |
| + throw new FormatException( |
| + 'Package "${collisions.first}" cannot appear in both "dependencies" ' |
| + 'and "dev_dependencies".'); |
|
nweiz
2013/03/13 18:46:29
Let's list all the collisions so users don't have
Bob Nystrom
2013/03/13 19:42:44
Done.
|
| + } |
| + |
| var environmentYaml = parsedPubspec['environment']; |
| var sdkConstraint = VersionConstraint.any; |
| if (environmentYaml != null) { |
| @@ -169,7 +188,8 @@ class Pubspec { |
| } |
| } |
| - return new Pubspec(name, version, dependencies, environment, parsedPubspec); |
| + return new Pubspec(name, version, dependencies, devDependencies, |
| + environment, parsedPubspec); |
| } |
| } |