Skip to content

Commit e4c11ce

Browse files
authored
adding a tweaks for stirng freezes (#272)
* adding a tweaks for stirng freezes Signed-off-by: John McCrae <[email protected]>
1 parent a13d216 commit e4c11ce

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

Rakefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,20 @@ task :console do
2222
IRB.start
2323
end
2424

25-
task default: %i{spec}
25+
task default: %i{style spec}
26+
27+
desc "Check Linting and code style."
28+
task :style do
29+
require "rubocop/rake_task"
30+
require "cookstyle/chefstyle"
31+
32+
if RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin/
33+
# Windows-specific command, rubocop erroneously reports the CRLF in each file which is removed when your PR is uploaeded to GitHub.
34+
# This is a workaround to ignore the CRLF from the files before running cookstyle.
35+
sh "cookstyle --chefstyle -c .rubocop.yml --except Layout/EndOfLine"
36+
else
37+
sh "cookstyle --chefstyle -c .rubocop.yml"
38+
end
39+
rescue LoadError
40+
puts "Rubocop or Cookstyle gems are not installed. bundle install first to make sure all dependencies are installed."
41+
end

lib/mixlib/shellout.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
#--
23
# Author:: Daniel DeLeo (<[email protected]>)
34
# Copyright:: Copyright (c) Chef Software Inc.
@@ -239,7 +240,7 @@ def timeout
239240
def format_for_exception
240241
return "Command execution failed. STDOUT/STDERR suppressed for sensitive resource" if sensitive
241242

242-
msg = ""
243+
msg = String.new
243244
msg << "#{@terminate_reason}\n" if @terminate_reason
244245
msg << "---- Begin output of #{command} ----\n"
245246
msg << "STDOUT: #{stdout.strip}\n"
@@ -269,7 +270,9 @@ def exitstatus
269270
# within +timeout+ seconds (default: 600s)
270271
def run_command
271272
if logger
272-
log_message = (log_tag.nil? ? "" : "#{@log_tag} ") << "sh(#{@command})"
273+
prefix = log_tag.nil? ? "" : "#{@log_tag} "
274+
log_message = prefix + "sh(#{@command})"
275+
# log_message = (log_tag.nil? ? "" : "#{@log_tag} ") << "sh(#{@command})"
273276
logger.send(log_level, log_message)
274277
end
275278
super

lib/mixlib/shellout/unix.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12
#
23
# Author:: Daniel DeLeo (<[email protected]>)
34
# Copyright:: Copyright (c) Chef Software Inc.

0 commit comments

Comments
 (0)