From 56ad706f4e9232eb9c0bc00b0edd78dfeac8ec62 Mon Sep 17 00:00:00 2001 From: William Johnston Date: Mon, 18 Jan 2016 11:13:22 -0600 Subject: [PATCH] Refactor display_error_message to simplify. --- lib/capistrano/application.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/capistrano/application.rb b/lib/capistrano/application.rb index 084fcfa5..d7f7c2b2 100644 --- a/lib/capistrano/application.rb +++ b/lib/capistrano/application.rb @@ -63,13 +63,10 @@ module Capistrano def display_error_message(ex) unless options.backtrace - if (loc = Rake.application.find_rakefile_location) - whitelist = (@imported.dup << loc[0]).map{|f| File.absolute_path(f, loc[1])} - pattern = %r@^(?!#{whitelist.map{|p| Regexp.quote(p)}.join('|')})@ - Rake.application.options.suppress_backtrace_pattern = pattern - end - trace "(Backtrace restricted to imported tasks)" + Rake.application.options.suppress_backtrace_pattern = backtrace_pattern + trace '(Backtrace restricted to imported tasks)' end + super end @@ -83,6 +80,14 @@ module Capistrano private + def backtrace_pattern + loc = Rake.application.find_rakefile_location + return unless loc + + whitelist = (@imported.dup << loc[0]).map { |f| File.absolute_path(f, loc[1]) } + /^(?!#{whitelist.map { |p| Regexp.quote(p) }.join('|')})/ + end + def load_imports if options.show_tasks invoke 'load:defaults'