lib/u3d/unity_runner.rb in u3d-0.9.3 vs lib/u3d/unity_runner.rb in u3d-0.9.4
- old
+ new
@@ -26,21 +26,12 @@
module U3d
# Launches Unity with given arguments
class Runner
def run(installation, args, raw_logs: false)
- log_file = find_logFile_in_args(args)
+ log_file = find_and_prepare_logfile(installation, args)
- if log_file # we wouldn't want to do that for the default log file.
- File.delete(log_file) if File.file?(log_file) # We only delete real files
- else
- log_file = installation.default_log_file
- end
-
- Utils.ensure_dir File.dirname(log_file)
- FileUtils.touch(log_file) unless File.exist? log_file
-
tail_thread = Thread.new do
begin
if raw_logs
pipe(log_file) { |l| UI.message l.rstrip }
else
@@ -62,31 +53,49 @@
if Helper.windows?
args.map! { |a| a =~ / / ? "\"#{a}\"" : a }
else
args.map!(&:shellescape)
end
-
+
U3dCore::CommandExecutor.execute(command: args, print_all: true)
ensure
sleep 1
Thread.kill(tail_thread)
end
end
- def find_logFile_in_args(args)
- find_arg_in_args('-logFile', args)
- end
+ def find_and_prepare_logfile(installation, args)
+ log_file = Runner.find_logFile_in_args(args)
- def find_projectpath_in_args(args)
- find_arg_in_args('-projectpath', args)
+ if log_file # we wouldn't want to do that for the default log file.
+ File.delete(log_file) if File.file?(log_file) # We only delete real files
+ else
+ log_file = installation.default_log_file
+ end
+
+ Utils.ensure_dir File.dirname(log_file)
+ FileUtils.touch(log_file) unless File.exist? log_file
+ log_file
end
- def find_arg_in_args(arg_to_find, args)
- raise 'Only arguments of type array supported right now' unless args.is_a?(Array)
- args.each_with_index do |arg, index|
- return args[index + 1] if arg == arg_to_find && index < args.count - 1
+ class << self
+ # rubocop:disable MethodName
+ def find_logFile_in_args(args)
+ # rubocop:enable MethodName
+ find_arg_in_args('-logFile', args)
end
- nil
+
+ def find_projectpath_in_args(args)
+ find_arg_in_args('-projectpath', args)
+ end
+
+ def find_arg_in_args(arg_to_find, args)
+ raise 'Only arguments of type array supported right now' unless args.is_a?(Array)
+ args.each_with_index do |arg, index|
+ return args[index + 1] if arg == arg_to_find && index < args.count - 1
+ end
+ nil
+ end
end
private
def pipe(file)