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

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

Issue 14680005: Add offline support to pub install and update. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 7 years, 7 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/bin/pub.dart ('k') | sdk/lib/_internal/pub/lib/src/command_install.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/command.dart
diff --git a/sdk/lib/_internal/pub/lib/src/command.dart b/sdk/lib/_internal/pub/lib/src/command.dart
index 21ad9b6cb23e5c2605e52b369e4e78dca2a72eb3..fb0a8423390ce0c8568814eb6e3ee2368fed516c 100644
--- a/sdk/lib/_internal/pub/lib/src/command.dart
+++ b/sdk/lib/_internal/pub/lib/src/command.dart
@@ -69,9 +69,13 @@ abstract class PubCommand {
/// available in [commandOptions].
ArgParser get commandParser => new ArgParser();
- void run(SystemCache cache_, ArgResults globalOptions_,
+ /// Override this to use offline-only sources instead of hitting the network.
+ /// This will only be called before the [SystemCache] is created. After that,
+ /// it has no effect.
+ bool get isOffline => false;
+
+ void run(String cacheDir, ArgResults globalOptions_,
List<String> commandArgs) {
- cache = cache_;
globalOptions = globalOptions_;
try {
@@ -82,6 +86,8 @@ abstract class PubCommand {
exit(exit_codes.USAGE);
}
+ cache = new SystemCache.withSources(cacheDir, isOffline: isOffline);
+
handleError(error) {
var trace = getAttachedStackTrace(error);
@@ -139,7 +145,7 @@ and include the results in a bug report on http://dartbug.com/new.
if (commandFuture == null) return true;
return commandFuture;
- }).whenComplete(() => cache_.deleteTempDir()).catchError((e) {
+ }).whenComplete(() => cache.deleteTempDir()).catchError((e) {
if (e is PubspecNotFoundException && e.name == null) {
e = 'Could not find a file named "pubspec.yaml" in the directory '
'${path.current}.';
« no previous file with comments | « sdk/lib/_internal/pub/bin/pub.dart ('k') | sdk/lib/_internal/pub/lib/src/command_install.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698