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

Unified Diff: sdk/lib/_internal/pub/lib/src/system_cache.dart

Issue 805393002: Update pub to use the new command runner API in args. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 5 years, 11 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
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/log.dart ('k') | sdk/lib/_internal/pub/test/cache/add/bad_version_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 650861522274b37a151e5b3a53a404d73f272ede..424585da3a091c116a287c7ee6f1d688cc82f0e8 100644
--- a/sdk/lib/_internal/pub/lib/src/system_cache.dart
+++ b/sdk/lib/_internal/pub/lib/src/system_cache.dart
@@ -5,6 +5,7 @@
library pub.system_cache;
import 'dart:async';
+import 'dart:io';
import 'package:path/path.dart' as path;
@@ -33,15 +34,27 @@ class SystemCache {
/// The sources from which to get packages.
final sources = new SourceRegistry();
+ static String defaultDir = (() {
+ if (Platform.environment.containsKey('PUB_CACHE')) {
+ return Platform.environment['PUB_CACHE'];
+ } else if (Platform.operatingSystem == 'windows') {
+ var appData = Platform.environment['APPDATA'];
+ return path.join(appData, 'Pub', 'Cache');
+ } else {
+ return '${Platform.environment['HOME']}/.pub-cache';
+ }
+ })();
+
/// Creates a new package cache which is backed by the given directory on the
/// user's file system.
- SystemCache(this.rootDir);
+ SystemCache([String rootDir])
+ : rootDir = rootDir == null ? SystemCache.defaultDir : 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: false}) {
+ factory SystemCache.withSources({String rootDir, bool isOffline: false}) {
var cache = new SystemCache(rootDir);
cache.register(new GitSource());
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/log.dart ('k') | sdk/lib/_internal/pub/test/cache/add/bad_version_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698