From 51698a70d1f500a8c8c68ecb80c5db07bd85123d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Thu, 9 May 2024 20:55:13 +0800 Subject: [PATCH] Fix bug. --- lib/tasks/exec_command.rake | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/tasks/exec_command.rake b/lib/tasks/exec_command.rake index 7b298ce..b6849cf 100644 --- a/lib/tasks/exec_command.rake +++ b/lib/tasks/exec_command.rake @@ -264,16 +264,16 @@ namespace :exec_commands do print data_str unless @no_stdout data_str.gsub!(/\r\n/, "\n") next if data_str.length == 0 - output_lines = data_str.split("\n") + output_lines = data_str.split("\n", -1) first_output = output_lines[0] if first_output if outputs.count != 0 outputs[-1] += first_output - # @remove_last_line = false - # outputs[-1] = outputs[-1].sub(/(.+)\r(.+)/) do |s| - # @remove_last_line = true - # first_output = $2 - # end + @remove_last_line = false + outputs[-1] = outputs[-1].sub(/(.+)\r(.+)/) do |s| + @remove_last_line = true + first_output = $2 + end else outputs << first_output end @@ -285,9 +285,6 @@ namespace :exec_commands do new_arr = output_lines[1..-1] new_arr = new_arr.map do |output_line| output_line = output_line.sub(/(.+)\r(.+)/, '\2') - end.select{|s| s.present?} - if data_str[-1] == "\n" - new_arr << "" end outputs += new_arr if update_outputs