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

Side by Side Diff: lib/src/command/cache_repair.dart

Issue 2184303002: Make pub strong-mode clean. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 years, 4 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
« no previous file with comments | « lib/src/command/build.dart ('k') | lib/src/command/deps.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 6
7 import '../command.dart'; 7 import '../command.dart';
8 import '../exit_codes.dart' as exit_codes; 8 import '../exit_codes.dart' as exit_codes;
9 import '../io.dart'; 9 import '../io.dart';
10 import '../log.dart' as log; 10 import '../log.dart' as log;
11 import '../source/cached.dart'; 11 import '../source/cached.dart';
12 import '../utils.dart'; 12 import '../utils.dart';
13 13
14 /// Handles the `cache repair` pub command. 14 /// Handles the `cache repair` pub command.
15 class CacheRepairCommand extends PubCommand { 15 class CacheRepairCommand extends PubCommand {
16 String get name => "repair"; 16 String get name => "repair";
17 String get description => "Reinstall cached packages."; 17 String get description => "Reinstall cached packages.";
18 String get invocation => "pub cache repair"; 18 String get invocation => "pub cache repair";
19 String get docUrl => "http://dartlang.org/tools/pub/cmd/pub-cache.html"; 19 String get docUrl => "http://dartlang.org/tools/pub/cmd/pub-cache.html";
20 bool get takesArguments => false; 20 bool get takesArguments => false;
21 21
22 Future run() async { 22 Future run() async {
23 var successes = []; 23 var successes = [];
24 var failures = []; 24 var failures = [];
25 25
26 // Repair every cached source. 26 // Repair every cached source.
27 for (var source in cache.sources.all.map(cache.source)) { 27 for (var source in cache.sources.all.map(cache.source)) {
28 if (source is! CachedSource) continue; 28 if (source is CachedSource) {
29 29 var results = await source.repairCachedPackages();
30 var results = await source.repairCachedPackages(); 30 successes.addAll(results.first);
31 successes.addAll(results.first); 31 failures.addAll(results.last);
32 failures.addAll(results.last); 32 }
33 } 33 }
34 34
35 if (successes.length > 0) { 35 if (successes.length > 0) {
36 var packages = pluralize("package", successes.length); 36 var packages = pluralize("package", successes.length);
37 log.message("Reinstalled ${log.green(successes.length)} $packages."); 37 log.message("Reinstalled ${log.green(successes.length)} $packages.");
38 } 38 }
39 39
40 if (failures.length > 0) { 40 if (failures.length > 0) {
41 var packages = pluralize("package", failures.length); 41 var packages = pluralize("package", failures.length);
42 var buffer = new StringBuffer( 42 var buffer = new StringBuffer(
(...skipping 25 matching lines...) Expand all
68 68
69 if (successes.length == 0 && failures.length == 0) { 69 if (successes.length == 0 && failures.length == 0) {
70 log.message("No packages in cache, so nothing to repair."); 70 log.message("No packages in cache, so nothing to repair.");
71 } 71 }
72 72
73 if (failures.length > 0 || results.last.length > 0) { 73 if (failures.length > 0 || results.last.length > 0) {
74 await flushThenExit(exit_codes.UNAVAILABLE); 74 await flushThenExit(exit_codes.UNAVAILABLE);
75 } 75 }
76 } 76 }
77 } 77 }
OLDNEW
« no previous file with comments | « lib/src/command/build.dart ('k') | lib/src/command/deps.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698