From 6591d7555210bac2a5ccbd3af5ca28f21ed526dd Mon Sep 17 00:00:00 2001 From: Takahiro HAMAGUCHI Date: Sun, 4 Oct 2015 00:35:38 +0900 Subject: [PATCH] * Added tty: true to execute commands with docker. * Modified log format with docker results. --- itamae.gemspec | 2 +- lib/itamae/backend.rb | 8 ++++++-- lib/itamae/logger.rb | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/itamae.gemspec b/itamae.gemspec index fa8f93a6..52de6c18 100644 --- a/itamae.gemspec +++ b/itamae.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.add_runtime_dependency "thor" - spec.add_runtime_dependency "specinfra", [">= 2.37.0", "< 3.0.0"] + spec.add_runtime_dependency "specinfra", [">= 2.43.11", "< 3.0.0"] spec.add_runtime_dependency "hashie" spec.add_runtime_dependency "ansi" spec.add_runtime_dependency "schash", "~> 0.1.0" diff --git a/lib/itamae/backend.rb b/lib/itamae/backend.rb index 85506887..7ccdb979 100644 --- a/lib/itamae/backend.rb +++ b/lib/itamae/backend.rb @@ -50,7 +50,7 @@ def run_command(commands, options = {}) Itamae.logger.with_indent do reset_output_handler - result = @backend.run_command(command) + result = @backend.run_command(command, options) flush_output_handler_buffer if result.exit_status == 0 || !options[:error] @@ -74,7 +74,7 @@ def run_command(commands, options = {}) end if options[:error] && result.exit_status != 0 - raise CommandExecutionError + fail CommandExecutionError, result.stderr end result @@ -248,6 +248,10 @@ def finalize Itamae.logger.info "Image created: #{image.id}" end + def run_command(commands, options = {}) + super(commands, options.merge({ tty: true })) + end + private def create_specinfra_backend begin diff --git a/lib/itamae/logger.rb b/lib/itamae/logger.rb index 498935c5..82423dca 100644 --- a/lib/itamae/logger.rb +++ b/lib/itamae/logger.rb @@ -48,7 +48,7 @@ def color(code, &block) %w!debug info warn error fatal unknown!.each do |level| module_eval(<<-EOC, __FILE__, __LINE__ + 1) def #{level}(msg) - super(" " * indent_depth + msg) + super(format("%s%s", " " * indent_depth, msg)) end EOC end