Commit bde1195c authored by Eloy Duran's avatar Eloy Duran

Immediately print output from Executable when in verbose mode.

Fixes #276.

I understand that the reason was to indent the output, but I think it's
more important to have instant feedback.

I went on a yak shaving, but now we can capture output and show it at
the same time. This should allow for better error checking. The problem
is that, for instance, Git (almost) always exits with non-zero exit
statusses, so that's not a good way to check it. We should probably
check the actual output.

This is all related to #266.
parent cc72284e
...@@ -6,18 +6,16 @@ module Pod ...@@ -6,18 +6,16 @@ module Pod
if bin.empty? if bin.empty?
raise Informative, "Unable to locate the executable `#{name}'" raise Informative, "Unable to locate the executable `#{name}'"
end end
full_command = "#{bin} #{command}"
if Config.instance.verbose? if Config.instance.verbose?
print " $ #{name}...\r" puts "$ #{full_command}"
$stdout.flush output = `#{full_command} 2>&1 | /usr/bin/tee /dev/tty`
output = `#{bin} #{command} 2>&1`
puts " #{$?.exitstatus.zero? ? '-' : '!'.red} #{name} #{command}"
output = output.gsub(/ */,' ').gsub(/^ */,' ')
puts output unless output.strip.empty?
else else
`#{bin} #{command} 2> /dev/null` output = `#{full_command} 2>&1`
end end
# TODO not sure that we should be silent in case of a failure.
puts "[!] Failed: #{full_command}".red unless Config.instance.silent? || $?.exitstatus.zero?
output
end end
private name private name
end end
......
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