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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 | 456 |
457 if (spec.containsKey('version')) { | 457 if (spec.containsKey('version')) { |
458 spec.remove('version'); | 458 spec.remove('version'); |
459 versionConstraint = _parseVersionConstraint( | 459 versionConstraint = _parseVersionConstraint( |
460 specNode.nodes['version']); | 460 specNode.nodes['version']); |
461 } | 461 } |
462 | 462 |
463 var sourceNames = spec.keys.toList(); | 463 var sourceNames = spec.keys.toList(); |
464 if (sourceNames.length > 1) { | 464 if (sourceNames.length > 1) { |
465 _error('A dependency may only have one source.', specNode.span); | 465 _error('A dependency may only have one source.', specNode.span); |
| 466 } else if (sourceNames.isEmpty) { |
| 467 _error('A dependency must contain a source.', specNode.span); |
466 } | 468 } |
467 | 469 |
468 sourceName = sourceNames.single; | 470 sourceName = sourceNames.single; |
469 if (sourceName is! String) { | 471 if (sourceName is! String) { |
470 _error('A source name must be a string.', | 472 _error('A source name must be a string.', |
471 specNode.nodes.keys.single.span); | 473 specNode.nodes.keys.single.span); |
472 } | 474 } |
473 | 475 |
474 descriptionNode = specNode.nodes[sourceName]; | 476 descriptionNode = specNode.nodes[sourceName]; |
475 } else { | 477 } else { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 implements ApplicationException { | 579 implements ApplicationException { |
578 PubspecException(String message, SourceSpan span) | 580 PubspecException(String message, SourceSpan span) |
579 : super(message, span); | 581 : super(message, span); |
580 } | 582 } |
581 | 583 |
582 /// Returns whether [uri] is a file URI. | 584 /// Returns whether [uri] is a file URI. |
583 /// | 585 /// |
584 /// This is slightly more complicated than just checking if the scheme is | 586 /// This is slightly more complicated than just checking if the scheme is |
585 /// 'file', since relative URIs also refer to the filesystem on the VM. | 587 /// 'file', since relative URIs also refer to the filesystem on the VM. |
586 bool _isFileUri(Uri uri) => uri.scheme == 'file' || uri.scheme == ''; | 588 bool _isFileUri(Uri uri) => uri.scheme == 'file' || uri.scheme == ''; |
OLD | NEW |