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:yaml/yaml.dart'; | 7 import 'package:yaml/yaml.dart'; |
8 import 'package:path/path.dart' as path; | 8 import 'package:path/path.dart' as path; |
9 | 9 |
10 import 'barback.dart'; | 10 import 'barback.dart'; |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 | 350 |
351 var versionConstraint = new VersionRange(); | 351 var versionConstraint = new VersionRange(); |
352 if (spec == null) { | 352 if (spec == null) { |
353 description = name; | 353 description = name; |
354 sourceName = _sources.defaultSource.name; | 354 sourceName = _sources.defaultSource.name; |
355 } else if (spec is String) { | 355 } else if (spec is String) { |
356 description = name; | 356 description = name; |
357 sourceName = _sources.defaultSource.name; | 357 sourceName = _sources.defaultSource.name; |
358 versionConstraint = _parseVersionConstraint(spec, "$field.$name"); | 358 versionConstraint = _parseVersionConstraint(spec, "$field.$name"); |
359 } else if (spec is Map) { | 359 } else if (spec is Map) { |
| 360 // Don't write to the immutable YAML map. |
| 361 spec = new Map.from(spec); |
| 362 |
360 if (spec.containsKey('version')) { | 363 if (spec.containsKey('version')) { |
361 versionConstraint = _parseVersionConstraint(spec.remove('version'), | 364 versionConstraint = _parseVersionConstraint(spec.remove('version'), |
362 "$field.$name.version"); | 365 "$field.$name.version"); |
363 } | 366 } |
364 | 367 |
365 var sourceNames = spec.keys.toList(); | 368 var sourceNames = spec.keys.toList(); |
366 if (sourceNames.length > 1) { | 369 if (sourceNames.length > 1) { |
367 _error('"$field.$name" field may only have one source, but it had ' | 370 _error('"$field.$name" field may only have one source, but it had ' |
368 '${toSentence(sourceNames)}.'); | 371 '${toSentence(sourceNames)}.'); |
369 } | 372 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 | 510 |
508 return "$str:\n$subMessage"; | 511 return "$str:\n$subMessage"; |
509 } | 512 } |
510 } | 513 } |
511 | 514 |
512 /// Returns whether [uri] is a file URI. | 515 /// Returns whether [uri] is a file URI. |
513 /// | 516 /// |
514 /// This is slightly more complicated than just checking if the scheme is | 517 /// This is slightly more complicated than just checking if the scheme is |
515 /// 'file', since relative URIs also refer to the filesystem on the VM. | 518 /// 'file', since relative URIs also refer to the filesystem on the VM. |
516 bool _isFileUri(Uri uri) => uri.scheme == 'file' || uri.scheme == ''; | 519 bool _isFileUri(Uri uri) => uri.scheme == 'file' || uri.scheme == ''; |
OLD | NEW |