improve startup time

This commit is contained in:
Devon Carew
2016-02-26 17:53:41 -08:00
parent 3c7ede15b0
commit 4e10bf596c
8 changed files with 207 additions and 92 deletions

View File

@@ -65,8 +65,12 @@ Future<Process> runDetached(List<String> cmd) {
/// Run cmd and return stdout.
/// Throws an error if cmd exits with a non-zero value.
String runCheckedSync(List<String> cmd, { String workingDirectory }) {
return _runWithLoggingSync(cmd, workingDirectory: workingDirectory, checked: true, noisyErrors: true);
String runCheckedSync(List<String> cmd, {
String workingDirectory, bool truncateCommand: false
}) {
return _runWithLoggingSync(
cmd, workingDirectory: workingDirectory, checked: true, noisyErrors: true, truncateCommand: truncateCommand
);
}
/// Run cmd and return stdout.
@@ -91,9 +95,13 @@ bool exitsHappy(List<String> cli) {
String _runWithLoggingSync(List<String> cmd, {
bool checked: false,
bool noisyErrors: false,
String workingDirectory
String workingDirectory,
bool truncateCommand: false
}) {
printTrace(cmd.join(' '));
String cmdText = cmd.join(' ');
if (truncateCommand && cmdText.length > 160)
cmdText = cmdText.substring(0, 160) + '…';
printTrace(cmdText);
ProcessResult results =
Process.runSync(cmd[0], cmd.getRange(1, cmd.length).toList(), workingDirectory: workingDirectory);
if (results.exitCode != 0) {

View File

@@ -3,6 +3,15 @@
// found in the LICENSE file.
import 'dart:async';
import 'dart:io';
import 'package:crypto/crypto.dart';
String calculateSha(File file) {
SHA1 sha1 = new SHA1();
sha1.add(file.readAsBytesSync());
return CryptoUtils.bytesToHex(sha1.close());
}
/// A class to maintain a list of items, fire events when items are added or
/// removed, and calculate a diff of changes when a new list of items is