| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library pub.pubspec; | 5 library pub.pubspec; |
| 6 | 6 |
| 7 import 'package:path/path.dart' as path; | 7 import 'package:path/path.dart' as path; |
| 8 import 'package:pub_semver/pub_semver.dart'; | 8 import 'package:pub_semver/pub_semver.dart'; |
| 9 import 'package:source_span/source_span.dart'; | 9 import 'package:source_span/source_span.dart'; |
| 10 import 'package:yaml/yaml.dart'; | 10 import 'package:yaml/yaml.dart'; |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 specNode.nodes.keys.single.span); | 489 specNode.nodes.keys.single.span); |
| 490 } | 490 } |
| 491 | 491 |
| 492 descriptionNode = specNode.nodes[sourceName]; | 492 descriptionNode = specNode.nodes[sourceName]; |
| 493 } else { | 493 } else { |
| 494 _error('A dependency specification must be a string or a mapping.', | 494 _error('A dependency specification must be a string or a mapping.', |
| 495 specNode.span); | 495 specNode.span); |
| 496 } | 496 } |
| 497 | 497 |
| 498 // Let the source validate the description. | 498 // Let the source validate the description. |
| 499 var description = _wrapFormatException('description', | 499 var ref = _wrapFormatException('description', descriptionNode.span, () { |
| 500 descriptionNode.span, () { | |
| 501 var pubspecPath; | 500 var pubspecPath; |
| 502 if (_location != null && _isFileUri(_location)) { | 501 if (_location != null && _isFileUri(_location)) { |
| 503 pubspecPath = path.fromUri(_location); | 502 pubspecPath = path.fromUri(_location); |
| 504 } | 503 } |
| 505 | 504 |
| 506 return _sources[sourceName].parseDescription( | 505 return _sources[sourceName].parseRef(name, descriptionNode.value, |
| 507 pubspecPath, descriptionNode.value, fromLockFile: false); | 506 containingPath: pubspecPath); |
| 508 }); | 507 }); |
| 509 | 508 |
| 510 dependencies.add(new PackageDep( | 509 dependencies.add(ref.withConstraint(versionConstraint)); |
| 511 name, sourceName, versionConstraint, description)); | |
| 512 }); | 510 }); |
| 513 | 511 |
| 514 return dependencies; | 512 return dependencies; |
| 515 } | 513 } |
| 516 | 514 |
| 517 /// Parses [node] to a [VersionConstraint]. | 515 /// Parses [node] to a [VersionConstraint]. |
| 518 VersionConstraint _parseVersionConstraint(YamlNode node) { | 516 VersionConstraint _parseVersionConstraint(YamlNode node) { |
| 519 if (node.value == null) return VersionConstraint.any; | 517 if (node.value == null) return VersionConstraint.any; |
| 520 if (node.value is! String) { | 518 if (node.value is! String) { |
| 521 _error('A version constraint must be a string.', node.span); | 519 _error('A version constraint must be a string.', node.span); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 implements ApplicationException { | 593 implements ApplicationException { |
| 596 PubspecException(String message, SourceSpan span) | 594 PubspecException(String message, SourceSpan span) |
| 597 : super(message, span); | 595 : super(message, span); |
| 598 } | 596 } |
| 599 | 597 |
| 600 /// Returns whether [uri] is a file URI. | 598 /// Returns whether [uri] is a file URI. |
| 601 /// | 599 /// |
| 602 /// This is slightly more complicated than just checking if the scheme is | 600 /// This is slightly more complicated than just checking if the scheme is |
| 603 /// 'file', since relative URIs also refer to the filesystem on the VM. | 601 /// 'file', since relative URIs also refer to the filesystem on the VM. |
| 604 bool _isFileUri(Uri uri) => uri.scheme == 'file' || uri.scheme == ''; | 602 bool _isFileUri(Uri uri) => uri.scheme == 'file' || uri.scheme == ''; |
| OLD | NEW |