lib/boxes/subprocess.rb in boxes-3.3.1 vs lib/boxes/subprocess.rb in boxes-3.4.0

- old
+ new

@@ -16,17 +16,14 @@ def self.run(command) # rubocop:disable Metrics/MethodLength # see: http://stackoverflow.com/a/1162850/83386 Open3.popen3(command) do |_stdin, stdout, stderr, thread| # read each stream from a new thread { out: stdout, err: stderr }.each do |key, stream| - Thread.new do - stream.each_line do |line| - # yield the block depending on the stream - if key == :out - yield line, nil, thread if block_given? - else - yield nil, line, thread if block_given? - end + stream.each_line do |line| + if key == :out + yield line, nil, thread if block_given? + elsif key == :err + yield nil, line, thread if block_given? end end end thread.join # don't exit until the external process is done