Skip to content

Commit

Permalink
Refactoring the sh command a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimweirich committed May 25, 2009
1 parent 34ddd30 commit 5f52524
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions lib/rake/file_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,9 @@ module FileUtils
#
def sh(*cmd, &block)
options = (Hash === cmd.last) ? cmd.pop : {}
unless block_given?
show_command = cmd.join(" ")
show_command = show_command[0,42] + "..." unless $trace
# TODO code application logic heref show_command.length > 45
block = lambda { |ok, status|
ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
}
end
block = create_shell_command(cmd) unless block_given?
set_verbose_option(options)
options[:noop] ||= RakeFileUtils.nowrite_flag
options[:noop] ||= RakeFileUtils.nowrite_flag
rake_check_options options, :noop, :verbose
rake_output_message cmd.join(" ") if options[:verbose]
unless options[:noop]
Expand All @@ -49,11 +42,17 @@ def sh(*cmd, &block)
end
end

def create_shell_command(cmd)
show_command = cmd.join(" ")
show_command = show_command[0,42] + "..." unless $trace
block = lambda { |ok, status|
ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
}
end

def set_verbose_option(options)
if RakeFileUtils.verbose_flag.nil? && options[:verbose].nil?
options[:verbose] = true
elsif options[:verbose].nil?
options[:verbose] ||= RakeFileUtils.verbose_flag
if options[:verbose].nil?
options[:verbose] = RakeFileUtils.verbose_flag.nil? || RakeFileUtils.verbose_flag
end
end
private :set_verbose_option
Expand Down

0 comments on commit 5f52524

Please sign in to comment.