| 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 63de5dc59899e0acff87082e84ad415d82eebbf1..adca55591e3647c02f3435cb1d0321abedfe55b4 100644
|
| --- a/sdk/lib/_internal/pub/lib/src/system_cache.dart
|
| +++ b/sdk/lib/_internal/pub/lib/src/system_cache.dart
|
| @@ -41,15 +41,25 @@ class SystemCache {
|
|
|
| /// Creates a new package cache which is backed by the given directory on the
|
| /// user's file system.
|
| - SystemCache(this.rootDir)
|
| - : _pendingInstalls = new Map<PackageId, Future<Package>>(),
|
| - sources = new SourceRegistry();
|
| + factory SystemCache() {
|
| + var cacheDir;
|
| + if (Platform.environment.containsKey('PUB_CACHE')) {
|
| + cacheDir = Platform.environment['PUB_CACHE'];
|
| + } else if (Platform.operatingSystem == 'windows') {
|
| + var appData = Platform.environment['APPDATA'];
|
| + cacheDir = path.join(appData, 'Pub', 'Cache');
|
| + } else {
|
| + cacheDir = '${Platform.environment['HOME']}/.pub-cache';
|
| + }
|
| +
|
| + return new SystemCache._(cacheDir);
|
| + }
|
|
|
| /// 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: false}) {
|
| - var cache = new SystemCache(rootDir);
|
| + factory SystemCache.withSources({bool isOffline: false}) {
|
| + var cache = new SystemCache();
|
| cache.register(new GitSource());
|
|
|
| if (isOffline) {
|
| @@ -63,6 +73,10 @@ class SystemCache {
|
| return cache;
|
| }
|
|
|
| + SystemCache._(this.rootDir)
|
| + : _pendingInstalls = new Map<PackageId, Future<Package>>(),
|
| + sources = new SourceRegistry();
|
| +
|
| /// Registers a new source. This source must not have the same name as a
|
| /// source that's already been registered.
|
| void register(Source source) {
|
|
|