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

Unified Diff: utils/pub/hosted_source.dart

Issue 12755024: add cache list command to pub (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: utils/pub/hosted_source.dart
===================================================================
--- utils/pub/hosted_source.dart (revision 19836)
+++ utils/pub/hosted_source.dart (working copy)
@@ -118,6 +118,22 @@
return description;
}
+ /// Returns a list of packages in the default cache
Bob Nystrom 2013/03/12 22:12:03 Remove this comment.
keertip 2013/03/13 15:55:00 Done.
+ Future<List<Package>> getCachedPackages() {
+ var url = _defaultUrl.replaceAll(new RegExp(r"^https?://"), "");
Bob Nystrom 2013/03/12 22:12:03 Can you pull this out into a separate function and
keertip 2013/03/13 15:55:00 Done.
+ return listDir(path.join(systemCacheRoot,url)).then((entries){
Bob Nystrom 2013/03/12 22:12:03 Space after "," and between ")" and "{".
keertip 2013/03/13 15:55:00 Done.
+ var list = new List();
+ for (var entry in entries) {
+ var name = path.basename(entry).replaceAll(new RegExp(r"-(.*)"),"");
Bob Nystrom 2013/03/12 22:12:03 How about: path.basename(entry).split('-')[0];
nweiz 2013/03/12 22:58:48 Both of these are dangerous if a package has a hyp
+ var p = new Package.load(name, entry, systemCache.sources);
+ list.add(p);
+ }
+ return list;
Bob Nystrom 2013/03/12 22:12:03 return entries.map((entry) { var name = ... re
keertip 2013/03/13 15:55:00 Done.
+ }).catchError((ex) {
+ throw 'Could not list packages in pub cache ${ex}';
Bob Nystrom 2013/03/12 22:12:03 Don't bother catching this.
keertip 2013/03/13 15:55:00 Done.
+ });
+ }
+
/// When an error occurs trying to read something about [package] from [url],
/// this tries to translate into a more user friendly error message. Always
/// throws an error, either the original one or a better one.

Powered by Google App Engine
This is Rietveld 408576698