10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/wicked_pdf/progress.rb', line 10
def invoke_with_progress(command, options)
output = []
begin
PTY.spawn(command.join(' ')) do |stdout, _stdin, pid|
begin
stdout.sync
stdout.each_line("\r") do |line|
output << line.chomp
options[:progress].call(line) if options[:progress]
end
rescue Errno::EIO ensure
::Process.wait pid
end
end
rescue PTY::ChildExited
puts 'The child process exited!'
end
err = output.join('\n')
raise "#{command} failed (exitstatus 0). Output was: #{err}" unless $CHILD_STATUS && $CHILD_STATUS.exitstatus.zero?
end
|