Actually improving crazyfun-bazel integration for non-windows systems
(accidentally committed a wrong version of the file)
require 'pp'
+require 'open3'
require 'rake/task'
require 'rake_tasks/selenium_rake/checks'
require 'rakelib/bazel/task'
@@ -18,8 +19,26 @@ module Bazel
cmd_out = `#{cmd_line}`
cmd_exit_code = $?.success?
else
- cmd_out = `#{cmd_line}`
- cmd_exit_code = $?.success?
+ Open3.popen2e(*cmd) do |stdin, stdouts, wait|
+ is_running = true
+ stdin.close
+ cmd_out = ''
+ while is_running
+ begin
+ pipes = IO.select([stdouts])
+ if pipes.empty?
+ is_running = false
+ else
+ line = stdouts.readpartial(512)
+ cmd_out << line
+ STDOUT.print line if verbose
+ end
+ rescue EOFError
+ is_running = false
+ end
+ end
+ cmd_exit_code = wait.value.exitstatus
+ end
end
puts cmd_out if verbose
