Index: sdk/lib/_internal/pub/lib/src/entrypoint.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/entrypoint.dart b/sdk/lib/_internal/pub/lib/src/entrypoint.dart |
index 1f09a3a1caaa9c6fe49bf6281be863d3a72bf962..a45b34c3a5a26a2e83d058c329d0f86d81f611a2 100644 |
--- a/sdk/lib/_internal/pub/lib/src/entrypoint.dart |
+++ b/sdk/lib/_internal/pub/lib/src/entrypoint.dart |
@@ -154,6 +154,35 @@ class Entrypoint { |
return new LockFile.load(lockFilePath, cache.sources); |
} |
+ /// Determines whether or not the lockfile is out of date with respect to the |
+ /// pubspec. |
+ /// |
+ /// This will be `true` if there is no lockfile at all, or if the pubspec |
+ /// contains dependencies that are not in the lockfile or that don't match |
+ /// what's in there. |
nweiz
2013/07/30 19:34:36
Doesn't this return `false` in those cases?
Bob Nystrom
2013/07/30 21:35:32
Fixed. Originally wrote the method to be isLockFil
|
+ bool isLockFileUpToDate() { |
+ var lockFile = loadLockFile(); |
+ |
+ checkDependency(package) { |
+ var locked = lockFile.packages[package.name]; |
+ if (locked == null) return false; |
+ |
+ if (package.source != locked.source) return false; |
+ if (!package.constraint.allows(locked.version)) return false; |
+ |
+ var source = cache.sources[package.source]; |
+ if (!source.descriptionsEqual(package.description, |
+ locked.description)) return false; |
nweiz
2013/07/30 19:34:36
Style nit: I think if the if clause goes over one
Bob Nystrom
2013/07/30 21:35:32
Done.
|
+ |
+ return true; |
+ } |
+ |
+ if (!root.dependencies.every(checkDependency)) return false; |
+ if (!root.devDependencies.every(checkDependency)) return false; |
+ |
+ return true; |
+ } |
+ |
/// Saves a list of concrete package versions to the `pubspec.lock` file. |
void _saveLockFile(List<PackageId> packageIds) { |
var lockFile = new LockFile.empty(); |