From 647a57b5f490da3b9e0881b8f818ba9b4b586c59 Mon Sep 17 00:00:00 2001 From: Bohung Date: Wed, 1 Dec 2021 20:59:18 +0800 Subject: [PATCH] Fix bug. --- lib/tasks/exec_command.rake | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/tasks/exec_command.rake b/lib/tasks/exec_command.rake index b065fef..6bc8b9d 100644 --- a/lib/tasks/exec_command.rake +++ b/lib/tasks/exec_command.rake @@ -166,22 +166,36 @@ namespace :exec_commands do channel.send_data "#{@password}\n" else print "#{data}" + data_str = data.to_s if data.include?("\n") || outputs.empty? - output_lines = data.to_s.split("\n").select{|l| l.present?} - outputs += output_lines + output_lines = data_str.split("\n") + first_output = nil + if outputs.count != 0 + first_output = output_lines[0] + outputs[-1] += first_output + end + new_arr = output_lines[1..-1] + if data_str[-1] == "\n" + new_arr << "" + end + outputs += new_arr if update - update_thread_infos_for_exec(output_lines,false,true) if @flag - update_infos_for_exec(output_lines,false,true) + if first_output + update_thread_infos_for_exec(first_output,true) if @flag + update_infos_for_exec(first_output,true) + end + update_thread_infos_for_exec(new_arr,false,true) if @flag + update_infos_for_exec(new_arr,false,true) end else if outputs.count == 0 - outputs.push(data.to_s) + outputs.push(data_str) else - outputs[-1] += (data.to_s rescue "") + outputs[-1] += (data_str rescue "") end if update - update_thread_infos_for_exec(data,true) if @flag - update_infos_for_exec(data,true) + update_thread_infos_for_exec(data_str,true) if @flag + update_infos_for_exec(data_str,true) end end end