Chromium Code Reviews| Index: sdk/lib/_internal/pub/lib/src/system_cache.dart |
| diff --git a/sdk/lib/_internal/pub/lib/src/system_cache.dart b/sdk/lib/_internal/pub/lib/src/system_cache.dart |
| index 8a51912a6eb40de1247d4f5d47a647ee98579144..20ede9c59aa898c164a271dca4e0d7d8620b8cf7 100644 |
| --- a/sdk/lib/_internal/pub/lib/src/system_cache.dart |
| +++ b/sdk/lib/_internal/pub/lib/src/system_cache.dart |
| @@ -45,11 +45,21 @@ class SystemCache { |
| : _pendingInstalls = new Map<PackageId, Future<Package>>(), |
| sources = new SourceRegistry(); |
| - /// Creates a system cache and registers the standard set of sources. |
| - factory SystemCache.withSources(String rootDir) { |
| + /// Creates a system cache and registers the standard set of sources. If |
| + /// [isOffline] is `true`, then the offline hosted source will be used. |
| + /// Defaults to `false`. |
| + factory SystemCache.withSources(String rootDir, {bool isOffline}) { |
| + if (isOffline == null) isOffline = false; |
|
nweiz
2013/05/06 23:02:25
I think I prefer explicitly defaulting named boole
Bob Nystrom
2013/05/07 21:03:09
I don't like the syntax for named parameter defaul
|
| + |
| var cache = new SystemCache(rootDir); |
| cache.register(new GitSource()); |
| - cache.register(new HostedSource()); |
| + |
| + if (isOffline) { |
| + cache.register(new OfflineHostedSource()); |
| + } else { |
| + cache.register(new HostedSource()); |
| + } |
| + |
| cache.register(new PathSource()); |
| cache.sources.setDefault('hosted'); |
| return cache; |