diff --git a/lib/capistrano/tasks/rvm.rake b/lib/capistrano/tasks/rvm.rake index b2845db..b73d713 100644 --- a/lib/capistrano/tasks/rvm.rake +++ b/lib/capistrano/tasks/rvm.rake @@ -4,6 +4,7 @@ RVM_USER_PATH = "~/.rvm" namespace :rvm do desc "Prints the RVM and Ruby version on the target host" task :check do + next if should_skip on roles(fetch(:rvm_roles, :all)) do if fetch(:log_level) == :debug puts capture(:rvm, "version") @@ -14,6 +15,7 @@ namespace :rvm do end task :hook do + next if should_skip on roles(fetch(:rvm_roles, :all)) do rvm_path = fetch(:rvm_custom_path) rvm_path ||= case fetch(:rvm_type) @@ -43,6 +45,18 @@ namespace :rvm do end end +def should_skip + skip_rvm_for_tasks = fetch(:skip_rvm_for_tasks, []) + invoked_with_task = Rake.application.top_level_tasks.last + skip_rvm_for_tasks.any? do |t| + if t.is_a?(Regexp) + t.match(invoked_with_task) + else + t == invoked_with_task + end + end +end + Capistrano::DSL.stages.each do |stage| after stage, 'rvm:hook' after stage, 'rvm:check'