Commit e9a24510 authored by Devon Carew's avatar Devon Carew

fast fail update-packages

parent 5e3d8cf2
...@@ -10,14 +10,15 @@ import '../dart/pub.dart'; ...@@ -10,14 +10,15 @@ import '../dart/pub.dart';
import '../globals.dart'; import '../globals.dart';
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
/// Return the total number of projects run; throws the exit code on error.
Future<int> _runPub(Directory directory, { bool upgrade: false }) async { Future<int> _runPub(Directory directory, { bool upgrade: false }) async {
int updateCount = 0; int updateCount = 0;
for (FileSystemEntity dir in directory.listSync()) { for (FileSystemEntity dir in directory.listSync()) {
if (dir is Directory && FileSystemEntity.isFileSync(dir.path + Platform.pathSeparator + 'pubspec.yaml')) { if (dir is Directory && FileSystemEntity.isFileSync(dir.path + Platform.pathSeparator + 'pubspec.yaml')) {
updateCount++; updateCount++;
// TODO(eseidel): Should this fail immediately if pubGet fails? int code = await pubGet(directory: dir.path, upgrade: upgrade, checkLastModified: false);
// Currently we're ignoring the return code. if (code != 0)
await pubGet(directory: dir.path, upgrade: upgrade, checkLastModified: false); throw code;
} }
} }
return updateCount; return updateCount;
...@@ -46,13 +47,20 @@ class UpdatePackagesCommand extends FlutterCommand { ...@@ -46,13 +47,20 @@ class UpdatePackagesCommand extends FlutterCommand {
@override @override
Future<int> runInProject() async { Future<int> runInProject() async {
Stopwatch timer = new Stopwatch()..start(); try {
int count = 0; Stopwatch timer = new Stopwatch()..start();
bool upgrade = argResults['upgrade']; int count = 0;
count += await _runPub(new Directory("${ArtifactStore.flutterRoot}/packages"), upgrade: upgrade); bool upgrade = argResults['upgrade'];
count += await _runPub(new Directory("${ArtifactStore.flutterRoot}/examples"), upgrade: upgrade);
count += await _runPub(new Directory("${ArtifactStore.flutterRoot}/dev"), upgrade: upgrade); count += await _runPub(new Directory("${ArtifactStore.flutterRoot}/packages"), upgrade: upgrade);
printStatus('Ran "pub" $count time${count == 1 ? "" : "s"} in ${timer.elapsedMilliseconds} ms'); count += await _runPub(new Directory("${ArtifactStore.flutterRoot}/examples"), upgrade: upgrade);
return 0; count += await _runPub(new Directory("${ArtifactStore.flutterRoot}/dev"), upgrade: upgrade);
printStatus('Ran "pub" $count time${count == 1 ? "" : "s"} in ${timer.elapsedMilliseconds} ms');
return 0;
} on int catch (code) {
return code;
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment