Module: ChefCLI::RecipeDSLExt

Defined in:
lib/chef-cli/command/generator_commands/chef_exts/recipe_dsl_ext.rb

Overview

Methods here are mixed in to the Chef recipe DSL to provide extra functionality for generator cookbooks.

Instance Method Summary collapse

Instance Method Details

#silence_chef_formatterObject

Replaces the current formatter (by default this is the ‘doc` formatter) with the null formatter, thus suppressing normal Chef output.



28
29
30
31
32
33
34
# File 'lib/chef-cli/command/generator_commands/chef_exts/recipe_dsl_ext.rb', line 28

def silence_chef_formatter
  old = run_context.events.subscribers.first
  out, err = old.output.out, old.output.err
  run_context.events.subscribers.clear
  null_formatter = Chef::Formatters.new(:null, out, err)
  run_context.events.register(null_formatter)
end