Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: sdk/lib/_internal/pub/lib/src/entrypoint.dart

Issue 21147002: Install before starting the server if the lockfile is out of date. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.entrypoint; 5 library pub.entrypoint;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:path/path.dart' as path; 9 import 'package:path/path.dart' as path;
10 10
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 148
149 /// Loads the list of concrete package versions from the `pubspec.lock`, if it 149 /// Loads the list of concrete package versions from the `pubspec.lock`, if it
150 /// exists. If it doesn't, this completes to an empty [LockFile]. 150 /// exists. If it doesn't, this completes to an empty [LockFile].
151 LockFile loadLockFile() { 151 LockFile loadLockFile() {
152 var lockFilePath = path.join(root.dir, 'pubspec.lock'); 152 var lockFilePath = path.join(root.dir, 'pubspec.lock');
153 if (!entryExists(lockFilePath)) return new LockFile.empty(); 153 if (!entryExists(lockFilePath)) return new LockFile.empty();
154 return new LockFile.load(lockFilePath, cache.sources); 154 return new LockFile.load(lockFilePath, cache.sources);
155 } 155 }
156 156
157 /// Determines whether or not the lockfile is out of date with respect to the
158 /// pubspec.
159 ///
160 /// This will be `true` if there is no lockfile at all, or if the pubspec
161 /// contains dependencies that are not in the lockfile or that don't match
162 /// 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
163 bool isLockFileUpToDate() {
164 var lockFile = loadLockFile();
165
166 checkDependency(package) {
167 var locked = lockFile.packages[package.name];
168 if (locked == null) return false;
169
170 if (package.source != locked.source) return false;
171 if (!package.constraint.allows(locked.version)) return false;
172
173 var source = cache.sources[package.source];
174 if (!source.descriptionsEqual(package.description,
175 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.
176
177 return true;
178 }
179
180 if (!root.dependencies.every(checkDependency)) return false;
181 if (!root.devDependencies.every(checkDependency)) return false;
182
183 return true;
184 }
185
157 /// Saves a list of concrete package versions to the `pubspec.lock` file. 186 /// Saves a list of concrete package versions to the `pubspec.lock` file.
158 void _saveLockFile(List<PackageId> packageIds) { 187 void _saveLockFile(List<PackageId> packageIds) {
159 var lockFile = new LockFile.empty(); 188 var lockFile = new LockFile.empty();
160 for (var id in packageIds) { 189 for (var id in packageIds) {
161 if (!id.isRoot) lockFile.packages[id.name] = id; 190 if (!id.isRoot) lockFile.packages[id.name] = id;
162 } 191 }
163 192
164 var lockFilePath = path.join(root.dir, 'pubspec.lock'); 193 var lockFilePath = path.join(root.dir, 'pubspec.lock');
165 writeTextFile(lockFilePath, lockFile.serialize()); 194 writeTextFile(lockFilePath, lockFile.serialize());
166 } 195 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // Skip directories and broken symlinks. 287 // Skip directories and broken symlinks.
259 if (!fileExists(file)) return false; 288 if (!fileExists(file)) return false;
260 289
261 var relative = path.relative(file, from: beneath); 290 var relative = path.relative(file, from: beneath);
262 if (_BLACKLISTED_FILES.contains(path.basename(relative))) return false; 291 if (_BLACKLISTED_FILES.contains(path.basename(relative))) return false;
263 return !path.split(relative).any(_BLACKLISTED_DIRS.contains); 292 return !path.split(relative).any(_BLACKLISTED_DIRS.contains);
264 }).toList(); 293 }).toList();
265 }); 294 });
266 } 295 }
267 } 296 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698