static WorkbookPackageTests() { void Git(string dir, params string [] args) => new Exec( ProcessArguments.FromCommandAndArguments("git", args), outputRedirection: null, workingDirectory: dir).RunAsync().GetAwaiter().GetResult(); if (PathToExternalWorkbooks.DirectoryExists) { Git(PathToExternalWorkbooks, "pull", "--rebase"); Git(PathToExternalWorkbooks, "submodule", "sync"); Git(PathToExternalWorkbooks, "submodule", "update", "--recursive", "--init"); } else { Git( PathToExternalWorkbooks.ParentDirectory, "clone", "--recursive", "https://github.com/xamarin/workbooks", PathToExternalWorkbooks.Name); } }
public static async Task <int> RunAsync( CancellationToken cancellationToken, Action <TimeSpan>?progressHandler, params string[] arguments) { var commandLine = ProcessArguments.FromCommandAndArguments(Path, arguments); Log.Debug("Exec {Path} {Arguments}", Path, arguments); TimeSpan progress = default; progressHandler?.Invoke(progress); return((await Exec.RunAsync(output => { switch (output.FileDescriptor) { case ConsoleRedirection.FileDescriptor.Output: Log.Debug("ffmpeg: {stdout}", output.Data.TrimEnd('\r', '\n')); break; case ConsoleRedirection.FileDescriptor.Error: Log.Debug("ffmpeg: {stderr}", output.Data.TrimEnd('\r', '\n')); var match = timespanRegex.Match(output.Data); if (match.Success && match.Groups.TryGetValue("timespan", out var timespanGroup) && TimeSpan.TryParse(timespanGroup.Value, out var timespan) && timespan != progress) { progress = timespan; progressHandler?.Invoke(progress); } break; } }, Path, arguments).ConfigureAwait(false)).ExitCode ?? -1); }