| 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 /// field, this will throw a [PubspecError]. | 341 /// field, this will throw a [PubspecError]. |
| 342 factory Pubspec.load(String packageDir, SourceRegistry sources, | 342 factory Pubspec.load(String packageDir, SourceRegistry sources, |
| 343 {String expectedName}) { | 343 {String expectedName}) { |
| 344 var pubspecPath = path.join(packageDir, 'pubspec.yaml'); | 344 var pubspecPath = path.join(packageDir, 'pubspec.yaml'); |
| 345 var pubspecUri = path.toUri(pubspecPath); | 345 var pubspecUri = path.toUri(pubspecPath); |
| 346 if (!fileExists(pubspecPath)) { | 346 if (!fileExists(pubspecPath)) { |
| 347 throw new FileException( | 347 throw new FileException( |
| 348 // Make the package dir absolute because for the entrypoint it'll just | 348 // Make the package dir absolute because for the entrypoint it'll just |
| 349 // be ".", which may be confusing. | 349 // be ".", which may be confusing. |
| 350 'Could not find a file named "pubspec.yaml" in ' | 350 'Could not find a file named "pubspec.yaml" in ' |
| 351 '"${path.normalize(path.absolute(packageDir))}".', | 351 '"${canonicalize(packageDir)}".', |
| 352 pubspecPath); | 352 pubspecPath); |
| 353 } | 353 } |
| 354 | 354 |
| 355 return new Pubspec.parse(readTextFile(pubspecPath), sources, | 355 return new Pubspec.parse(readTextFile(pubspecPath), sources, |
| 356 expectedName: expectedName, location: pubspecUri); | 356 expectedName: expectedName, location: pubspecUri); |
| 357 } | 357 } |
| 358 | 358 |
| 359 Pubspec(this._name, {Version version, Iterable<PackageDep> dependencies, | 359 Pubspec(this._name, {Version version, Iterable<PackageDep> dependencies, |
| 360 Iterable<PackageDep> devDependencies, | 360 Iterable<PackageDep> devDependencies, |
| 361 Iterable<PackageDep> dependencyOverrides, | 361 Iterable<PackageDep> dependencyOverrides, |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 implements ApplicationException { | 610 implements ApplicationException { |
| 611 PubspecException(String message, SourceSpan span) | 611 PubspecException(String message, SourceSpan span) |
| 612 : super(message, span); | 612 : super(message, span); |
| 613 } | 613 } |
| 614 | 614 |
| 615 /// Returns whether [uri] is a file URI. | 615 /// Returns whether [uri] is a file URI. |
| 616 /// | 616 /// |
| 617 /// This is slightly more complicated than just checking if the scheme is | 617 /// This is slightly more complicated than just checking if the scheme is |
| 618 /// 'file', since relative URIs also refer to the filesystem on the VM. | 618 /// 'file', since relative URIs also refer to the filesystem on the VM. |
| 619 bool _isFileUri(Uri uri) => uri.scheme == 'file' || uri.scheme == ''; | 619 bool _isFileUri(Uri uri) => uri.scheme == 'file' || uri.scheme == ''; |
| OLD | NEW |