From 5b221b81abfc54e51bc1a81bbdcaf62468c3941a Mon Sep 17 00:00:00 2001 From: Ryan Sonnek Date: Thu, 24 Sep 2015 13:37:56 -0500 Subject: [PATCH 1/2] Use popen to stream stdout and stderr Fix #23 --- lib/gitx/extensions/thor.rb | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/gitx/extensions/thor.rb b/lib/gitx/extensions/thor.rb index 7ac2447..475988a 100644 --- a/lib/gitx/extensions/thor.rb +++ b/lib/gitx/extensions/thor.rb @@ -1,14 +1,24 @@ -require 'English' +require 'open3' class Thor module Actions # execute a shell command and raise an error if non-zero exit code is returned # return the string output from the command - def run_cmd(cmd, options = {}) - say "$ #{cmd}" - output = `#{cmd}` - success = $CHILD_STATUS.to_i == 0 - fail "#{cmd} failed" unless success || options[:allow_failure] + def run_cmd(*args) + options = args.last.is_a?(Hash) ? args.pop : {} + cmd = args + say "$ #{cmd.join(' ')}", :yellow + output = '' + + Open3.popen2e(*cmd) do |stdin, stdout_err, wait_thr| + while line = stdout_err.gets + say line, :yellow + output << line + end + + exit_status = wait_thr.value + fail "#{cmd.join(' ')} failed" unless exit_status.success? || options[:allow_failure] + end output end From f8a31f3c34928082b92f8f60e02228301cee93dd Mon Sep 17 00:00:00 2001 From: Ryan Sonnek Date: Thu, 24 Sep 2015 13:47:23 -0500 Subject: [PATCH 2/2] bump version --- lib/gitx/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gitx/version.rb b/lib/gitx/version.rb index 058db7b..6c444d9 100644 --- a/lib/gitx/version.rb +++ b/lib/gitx/version.rb @@ -1,3 +1,3 @@ module Gitx - VERSION = '2.21.1' + VERSION = '2.21.2' end