Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,20 @@ task :console do
IRB.start
end

task default: %i{spec}
task default: %i{style spec}

desc "Check Linting and code style."
task :style do
require "rubocop/rake_task"
require "cookstyle/chefstyle"

if RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin/
# Windows-specific command, rubocop erroneously reports the CRLF in each file which is removed when your PR is uploaeded to GitHub.
# This is a workaround to ignore the CRLF from the files before running cookstyle.
sh "cookstyle --chefstyle -c .rubocop.yml --except Layout/EndOfLine"
else
sh "cookstyle --chefstyle -c .rubocop.yml"
end
rescue LoadError
puts "Rubocop or Cookstyle gems are not installed. bundle install first to make sure all dependencies are installed."
end
7 changes: 5 additions & 2 deletions lib/mixlib/shellout.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#--
# Author:: Daniel DeLeo (<[email protected]>)
# Copyright:: Copyright (c) Chef Software Inc.
Expand Down Expand Up @@ -239,7 +240,7 @@ def timeout
def format_for_exception
return "Command execution failed. STDOUT/STDERR suppressed for sensitive resource" if sensitive

msg = ""
msg = String.new
msg << "#{@terminate_reason}\n" if @terminate_reason
msg << "---- Begin output of #{command} ----\n"
msg << "STDOUT: #{stdout.strip}\n"
Expand Down Expand Up @@ -269,7 +270,9 @@ def exitstatus
# within +timeout+ seconds (default: 600s)
def run_command
if logger
log_message = (log_tag.nil? ? "" : "#{@log_tag} ") << "sh(#{@command})"
prefix = log_tag.nil? ? "" : "#{@log_tag} "
log_message = prefix + "sh(#{@command})"
# log_message = (log_tag.nil? ? "" : "#{@log_tag} ") << "sh(#{@command})"
logger.send(log_level, log_message)
end
super
Expand Down
1 change: 1 addition & 0 deletions lib/mixlib/shellout/unix.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# Author:: Daniel DeLeo (<[email protected]>)
# Copyright:: Copyright (c) Chef Software Inc.
Expand Down