5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/pangea-orchestrator/shell.rb', line 5
def run(command)
Open3.popen3(command) do |_stdin, stdout, stderr, wait_thr|
stdout.each_line do |line|
parsed = JSON.parse(line.strip)
puts JSON.pretty_generate(parsed)
puts "\n---\n" rescue JSON::ParserError
warn "⚠️ Invalid JSON received: #{line.inspect}"
end
unless (err = stderr.read).empty?
warn "\n❌ Command errors:\n#{err}"
end
exit_status = wait_thr.value
warn "\n🔥 Command failed with status #{exit_status.exitstatus}" unless exit_status.success?
end
end
|