From a21eb746e5397bb741e99c28d0c19a53f9f24a25 Mon Sep 17 00:00:00 2001 From: Cyril Duchon-Doris Date: Wed, 12 Dec 2018 13:17:38 +0100 Subject: [PATCH 1/2] Ability to require without hooks --- README.md | 19 +++++++++++++++++++ lib/capistrano/hooks/rvm.rb | 4 ++++ lib/capistrano/rvm/without_hooks.rb | 1 + lib/capistrano/tasks/deploy_rvm.rake | 2 ++ lib/capistrano/tasks/rvm.rake | 5 ----- 5 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 lib/capistrano/hooks/rvm.rb create mode 100644 lib/capistrano/rvm/without_hooks.rb create mode 100644 lib/capistrano/tasks/deploy_rvm.rake diff --git a/README.md b/README.md index 623ea93..e75b867 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,25 @@ Require in Capfile to use the default task: And you should be good to go! +### Explicitely require hooks + +Alternatively, if you want to have control on the execution of nvm tasks + +```ruby +# Capfile +require capistrano/rbenv/without_hooks +``` + +You can then add the hooks on a per deploy script basis + +```ruby +# config/deploy/my_stage_with_rvm.rb +Capistrano::DSL.stages.each do |stage| + after stage, 'rvm:hook' + after stage, 'rvm:check' +end +``` + ## Configuration Everything *should work* for a basic RVM setup *out of the box*. diff --git a/lib/capistrano/hooks/rvm.rb b/lib/capistrano/hooks/rvm.rb new file mode 100644 index 0000000..329eafc --- /dev/null +++ b/lib/capistrano/hooks/rvm.rb @@ -0,0 +1,4 @@ +Capistrano::DSL.stages.each do |stage| + after stage, 'rvm:hook' + after stage, 'rvm:check' +end diff --git a/lib/capistrano/rvm/without_hooks.rb b/lib/capistrano/rvm/without_hooks.rb new file mode 100644 index 0000000..261649b --- /dev/null +++ b/lib/capistrano/rvm/without_hooks.rb @@ -0,0 +1 @@ +load File.expand_path('../../tasks/rvm.rb', __FILE__) diff --git a/lib/capistrano/tasks/deploy_rvm.rake b/lib/capistrano/tasks/deploy_rvm.rake new file mode 100644 index 0000000..246c80f --- /dev/null +++ b/lib/capistrano/tasks/deploy_rvm.rake @@ -0,0 +1,2 @@ +load File.expand_path('../rvm.rake', __FILE__) +load File.expand_path('../../hooks/rvm.rb', __FILE__) diff --git a/lib/capistrano/tasks/rvm.rake b/lib/capistrano/tasks/rvm.rake index b2845db..86d0693 100644 --- a/lib/capistrano/tasks/rvm.rake +++ b/lib/capistrano/tasks/rvm.rake @@ -43,11 +43,6 @@ namespace :rvm do end end -Capistrano::DSL.stages.each do |stage| - after stage, 'rvm:hook' - after stage, 'rvm:check' -end - namespace :load do task :defaults do set :rvm_map_bins, %w{gem rake ruby bundle} From 9403206128490b5939c8182f0836645a63fc0d96 Mon Sep 17 00:00:00 2001 From: Cyril Duchon-Doris Date: Wed, 12 Dec 2018 13:58:43 +0100 Subject: [PATCH 2/2] Fix a silly mistake --- lib/capistrano/rvm/without_hooks.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/capistrano/rvm/without_hooks.rb b/lib/capistrano/rvm/without_hooks.rb index 261649b..74f4fe1 100644 --- a/lib/capistrano/rvm/without_hooks.rb +++ b/lib/capistrano/rvm/without_hooks.rb @@ -1 +1 @@ -load File.expand_path('../../tasks/rvm.rb', __FILE__) +load File.expand_path('../../tasks/rvm.rake', __FILE__)