lib/makit/command_runner.rb in makit-0.0.10 vs lib/makit/command_runner.rb in makit-0.0.11

- old
+ new

@@ -50,11 +50,13 @@ #cache_filename = Makit::Directories::PROJECT_ARTIFACTS + "/commands/#{command_request.name}.#{command_request.arguments.join("_")}.#{timestamp.seconds}.pb" if File.exist?(cache_filename) #puts "cache file date: #{File.mtime(cache_filename)}" if (File.mtime(cache_filename) > timestamp) #puts "cache_filename exists and is newer than #{timestamp}" - return Makit::Serializer.open(cache_filename, Makit::V1::Command) + command = Makit::Serializer.open(cache_filename, Makit::V1::Command) + show_command(command) + return command #Makit::Serializer.open(cache_filename, Makit::V1::Command) else #puts "cache_filename exists, but is older than #{timestamp}" end end @@ -65,18 +67,11 @@ Makit::Serializer.save_as(cache_filename, command) commands.push(command) command end - # Run a command and return a Makit::V1::Command. - def run(command_request) - raise "Invalid command_request" unless command_request.is_a? Makit::V1::CommandRequest - command = execute(command_request) - show_output = true - exit_on_error = true - - log_to_artifacts(command) if @log_to_artifacts + def show_command(command) if command.exit_code != 0 puts Makit::CommandRunner.get_command_summary(command) + " (exit code #{command.exit_code})".colorize(:default) puts " directory: #{command.directory}\n" puts " duration: #{command.duration.seconds} seconds\n" puts Makit::Humanize::indent_string(command.output, 2) if command.output.length > 0 @@ -84,9 +79,31 @@ exit 1 if command_request.exit_on_error else puts Makit::CommandRunner.get_command_summary(command) + " (#{command.duration.seconds} seconds)".colorize(:cyan) puts Makit::Humanize::indent_string(command.output, 2).colorize(:default) if show_output_on_success end + end + + # Run a command and return a Makit::V1::Command. + def run(command_request) + raise "Invalid command_request" unless command_request.is_a? Makit::V1::CommandRequest + command = execute(command_request) + show_output = true + exit_on_error = true + + log_to_artifacts(command) if @log_to_artifacts + show_command(command) + #if command.exit_code != 0 + # puts Makit::CommandRunner.get_command_summary(command) + " (exit code #{command.exit_code})".colorize(:default) + # puts " directory: #{command.directory}\n" + # puts " duration: #{command.duration.seconds} seconds\n" + # puts Makit::Humanize::indent_string(command.output, 2) if command.output.length > 0 + # puts Makit::Humanize::indent_string(command.error, 2) if command.error.length > 0 + # exit 1 if command_request.exit_on_error + #else + # puts Makit::CommandRunner.get_command_summary(command) + " (#{command.duration.seconds} seconds)".colorize(:cyan) + # puts Makit::Humanize::indent_string(command.output, 2).colorize(:default) if show_output_on_success + #end commands.push(command) command end