Add nicer logging/reporting to dev/update_packages.dart
Makes it more obvious where we are spending our time on Travis. Also added travis caching for the global pub cache to speed this up! Modeled what dartdoc does: https://github.com/dart-lang/dartdoc/blob/master/.travis.yml#L13 @Hixie
This commit is contained in:
parent
e1fefc061c
commit
d8e4fee9a0
@ -13,3 +13,6 @@ before_script:
|
|||||||
- ./travis/setup.sh
|
- ./travis/setup.sh
|
||||||
script:
|
script:
|
||||||
- ./travis/test.sh
|
- ./travis/test.sh
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/.pub-cache
|
||||||
|
@ -6,27 +6,40 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
final String binaryName = Platform.isWindows ? 'pub.bat' : 'pub';
|
final String binaryName = Platform.isWindows ? 'pub.bat' : 'pub';
|
||||||
void update(Directory directory, bool upgrade) {
|
int runPub(Directory directory, List<String> pubArgs) {
|
||||||
|
int updateCount = 0;
|
||||||
for (FileSystemEntity dir in directory.listSync()) {
|
for (FileSystemEntity dir in directory.listSync()) {
|
||||||
if (dir is Directory) {
|
if (dir is Directory) {
|
||||||
print("Updating ${dir.path}...");
|
updateCount++;
|
||||||
|
Stopwatch timer = new Stopwatch()..start();
|
||||||
|
stdout.write("Updating ${dir.path}...");
|
||||||
ProcessResult result = Process.runSync(
|
ProcessResult result = Process.runSync(
|
||||||
binaryName,
|
binaryName,
|
||||||
[ upgrade ? 'upgrade' : 'get' ],
|
pubArgs,
|
||||||
workingDirectory: dir.path
|
workingDirectory: dir.path
|
||||||
);
|
);
|
||||||
|
timer.stop();
|
||||||
|
stdout.write(" (${timer.elapsedMilliseconds} ms)");
|
||||||
if (result.exitCode != 0) {
|
if (result.exitCode != 0) {
|
||||||
print("... failed with exit code ${result.exitCode}.");
|
print("... failed with exit code ${result.exitCode}.");
|
||||||
print(result.stdout);
|
print(result.stdout);
|
||||||
print(result.stderr);
|
print(result.stderr);
|
||||||
|
} else {
|
||||||
|
stdout.write("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return updateCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(List<String> arguments) {
|
void main(List<String> arguments) {
|
||||||
|
Stopwatch timer = new Stopwatch()..start();
|
||||||
bool upgrade = arguments.length > 0 && arguments[0] == '--upgrade';
|
bool upgrade = arguments.length > 0 && arguments[0] == '--upgrade';
|
||||||
String FLUTTER_ROOT = new File(Platform.script.toFilePath()).parent.parent.path;
|
String FLUTTER_ROOT = new File(Platform.script.toFilePath()).parent.parent.path;
|
||||||
update(new Directory("$FLUTTER_ROOT/packages"), upgrade);
|
List<String> pubArgs = [ upgrade ? 'upgrade' : 'get' ];
|
||||||
update(new Directory("$FLUTTER_ROOT/examples"), upgrade);
|
int count = 0;
|
||||||
|
count += runPub(new Directory("$FLUTTER_ROOT/packages"), pubArgs);
|
||||||
|
count += runPub(new Directory("$FLUTTER_ROOT/examples"), pubArgs);
|
||||||
|
String command = "$binaryName ${pubArgs.join(' ')}";
|
||||||
|
print("Ran \"$command\" $count times in ${timer.elapsedMilliseconds} ms");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user