Method: WebpackNative::Runner#run
- Defined in:
- lib/webpack_native/runner.rb
#run ⇒ Runner
Run the command, return self
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/webpack_native/runner.rb', line 43 def run Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr| until [stdout, stderr].all?(&:eof?) readable = IO.select([stdout, stderr]) next unless readable&.first readable.first.each do |stream| data = +'' # rubocop:disable Lint/HandleExceptions begin stream.read_nonblock(1024, data) rescue EOFError # ignore, it's expected for read_nonblock to raise EOFError # when all is read end if stream == stdout @stdout << data $stdout.write(data) else @stderr << data $stderr.write(data) end end end @exit_status = wait_thr.value.exitstatus end self end |