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

Side by Side Diff: sdk/lib/_internal/pub/lib/src/command/cache_repair.dart

Issue 1165473002: Start pulling pub from its own repo. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Code review changes Created 5 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library pub.command.cache_repair;
6
7 import 'dart:async';
8
9 import '../command.dart';
10 import '../exit_codes.dart' as exit_codes;
11 import '../io.dart';
12 import '../log.dart' as log;
13 import '../source/cached.dart';
14 import '../utils.dart';
15
16 /// Handles the `cache repair` pub command.
17 class CacheRepairCommand extends PubCommand {
18 String get name => "repair";
19 String get description => "Reinstall cached packages.";
20 String get invocation => "pub cache repair";
21 String get docUrl => "http://dartlang.org/tools/pub/cmd/pub-cache.html";
22 bool get takesArguments => false;
23
24 Future run() async {
25 var successes = 0;
26 var failures = 0;
27
28 // Repair every cached source.
29 for (var source in cache.sources) {
30 if (source is! CachedSource) continue;
31
32 var results = await source.repairCachedPackages();
33 successes += results.first;
34 failures += results.last;
35 }
36
37 if (successes > 0) {
38 var packages = pluralize("package", successes);
39 log.message("Reinstalled ${log.green(successes)} $packages.");
40 }
41
42 if (failures > 0) {
43 var packages = pluralize("package", failures);
44 log.message("Failed to reinstall ${log.red(failures)} $packages.");
45 }
46
47 var results = await globals.repairActivatedPackages();
48 if (results.first > 0) {
49 var packages = pluralize("package", results.first);
50 log.message("Reactivated ${log.green(results.first)} $packages.");
51 }
52
53 if (results.last > 0) {
54 var packages = pluralize("package", results.last);
55 log.message("Failed to reactivate ${log.red(results.last)} $packages.");
56 }
57
58 if (successes == 0 && failures == 0) {
59 log.message("No packages in cache, so nothing to repair.");
60 }
61
62 if (failures > 0) await flushThenExit(exit_codes.UNAVAILABLE);
63 }
64 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/command/cache_list.dart ('k') | sdk/lib/_internal/pub/lib/src/command/deps.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698