Chromium Code Reviews| 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. |