Merge pull request #20 from dart-lang/devoncarew_return_none
return Version.none instead of null
diff --git a/lib/pub_cache.dart b/lib/pub_cache.dart
index 3f980e5..26ab298 100644
--- a/lib/pub_cache.dart
+++ b/lib/pub_cache.dart
@@ -143,7 +143,7 @@
/// The version of the application and of the defining package.
Version get version {
PackageRef ref = getDefiningPackageRef();
- return ref == null ? null : ref.version;
+ return ref == null ? Version.none : ref.version;
}
/// Return the reference to the defining package. This is the package that
diff --git a/lib/src/impl.dart b/lib/src/impl.dart
index 3a23de1..59bad03 100644
--- a/lib/src/impl.dart
+++ b/lib/src/impl.dart
@@ -118,11 +118,13 @@
}
// Parse the version.
+ _version = Version.none;
File f = new File(path.join(directory.path, 'pubspec.yaml'));
if (f.existsSync()) {
Map pubspec = yaml.loadYaml(f.readAsStringSync());
- _version = pubspec.containsKey('version')
- ? new Version.parse(pubspec['version']) : Version.none;
+ if (pubspec.containsKey('version')) {
+ _version = new Version.parse(pubspec['version']);
+ }
}
}