12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/capistrano/colorized_stream.rb', line 12
def stream_with_colorized(command, options={})
trap("INT") { puts 'Interupted'; exit 0; }
previous_last_line = Hash.new("")
invoke_command(command, options) do |ch, stream, out|
if stream == :out
hostname = ch[:host]
lines = out.split(/\r?\n/m, -1)
lines[0] = previous_last_line[hostname] + lines[0]
previous_last_line[hostname] = lines.pop
lines.each {|line| puts colorized(hostname) + line }
end
warn "[err :: #{ch[:server]}] #{out}" if stream == :err
end
end
|