Module: Chef::Mixin::ShellOut

Constant Summary collapse

DEPRECATED_OPTIONS =
[ [:command_log_level,   :log_level],
[:command_log_prepend, :log_tag] ]

Instance Method Summary collapse

Instance Method Details

#run_command_compatible_options(command_args) ⇒ Object

CHEF-3090: Deprecate command_log_level and command_log_prepend Patterned after github.com/opscode/chef/commit/e1509990b559984b43e428d4d801c394e970f432



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/chef/mixin/shell_out.rb', line 46

def run_command_compatible_options(command_args)
  return command_args unless command_args.last.is_a?(Hash)

  _command_args = command_args.dup
  _options = _command_args.last

  DEPRECATED_OPTIONS.each do |old_option, new_option|
    # Edge case: someone specifies :command_log_level and 'command_log_level' in the option hash
    next unless value = _options.delete(old_option) || _options.delete(old_option.to_s)
    deprecate_option old_option, new_option
    _options[new_option] = value
  end

  return _command_args
end

#shell_out(*command_args) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/chef/mixin/shell_out.rb', line 25

def shell_out(*command_args)
  cmd = Mixlib::ShellOut.new(*run_command_compatible_options(command_args))
  if STDOUT.tty? && !Chef::Config[:daemon] && Chef::Log.debug?
    cmd.live_stream = STDOUT
  end
  cmd.run_command
  cmd
end

#shell_out!(*command_args) ⇒ Object



34
35
36
37
38
# File 'lib/chef/mixin/shell_out.rb', line 34

def shell_out!(*command_args)
  cmd= shell_out(*command_args)
  cmd.error!
  cmd
end