From 224b6bf820407bcacf43dc489d2a30f7ed5878e6 Mon Sep 17 00:00:00 2001 From: Cyril Duchon-Doris Date: Wed, 12 Dec 2018 13:07:14 +0100 Subject: [PATCH 1/2] allow require without laoding hooks --- README.md | 19 +++++++++++++++++++ lib/capistrano/hooks/rbenv.rb | 4 ++++ lib/capistrano/rbenv.rb | 2 +- lib/capistrano/rbenv/without_hooks.rb | 1 + lib/capistrano/tasks/deploy_rbenv.rake | 2 ++ lib/capistrano/tasks/rbenv.rake | 5 ----- 6 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 lib/capistrano/hooks/rbenv.rb create mode 100644 lib/capistrano/rbenv/without_hooks.rb create mode 100644 lib/capistrano/tasks/deploy_rbenv.rake diff --git a/README.md b/README.md index d8a4145..1c7be5f 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,25 @@ To set the Ruby version explicitly, add `:rbenv_ruby` to your Capistrano configu Alternatively, allow the remote host's `rbenv` to [determine the appropriate Ruby version](https://github.com/rbenv/rbenv#choosing-the-ruby-version) by omitting `:rbenv_ruby`. This approach is useful if you have a `.ruby-version` file in your project. +### 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_nvm.rb +Capistrano::DSL.stages.each do |stage| + after stage, 'rbenv:validate' + after stage, 'rbenv:map_bins' +end +``` + ## Contributing 1. Fork it diff --git a/lib/capistrano/hooks/rbenv.rb b/lib/capistrano/hooks/rbenv.rb new file mode 100644 index 0000000..a871e0c --- /dev/null +++ b/lib/capistrano/hooks/rbenv.rb @@ -0,0 +1,4 @@ +Capistrano::DSL.stages.each do |stage| + after stage, 'rbenv:validate' + after stage, 'rbenv:map_bins' +end diff --git a/lib/capistrano/rbenv.rb b/lib/capistrano/rbenv.rb index 6305c85..7590123 100644 --- a/lib/capistrano/rbenv.rb +++ b/lib/capistrano/rbenv.rb @@ -1 +1 @@ -load File.expand_path("../tasks/rbenv.rake", __FILE__) +load File.expand_path('../tasks/deploy_rbenv.rake', __FILE__) diff --git a/lib/capistrano/rbenv/without_hooks.rb b/lib/capistrano/rbenv/without_hooks.rb new file mode 100644 index 0000000..ab310f0 --- /dev/null +++ b/lib/capistrano/rbenv/without_hooks.rb @@ -0,0 +1 @@ +load File.expand_path('../../tasks/rbenv.cap', __FILE__) diff --git a/lib/capistrano/tasks/deploy_rbenv.rake b/lib/capistrano/tasks/deploy_rbenv.rake new file mode 100644 index 0000000..499ff2f --- /dev/null +++ b/lib/capistrano/tasks/deploy_rbenv.rake @@ -0,0 +1,2 @@ +load File.expand_path('../rbenv.rake', __FILE__) +load File.expand_path('../../hooks/rbenv.cap', __FILE__) diff --git a/lib/capistrano/tasks/rbenv.rake b/lib/capistrano/tasks/rbenv.rake index 3a9db6e..45de2c1 100644 --- a/lib/capistrano/tasks/rbenv.rake +++ b/lib/capistrano/tasks/rbenv.rake @@ -25,11 +25,6 @@ namespace :rbenv do end end -Capistrano::DSL.stages.each do |stage| - after stage, 'rbenv:validate' - after stage, 'rbenv:map_bins' -end - namespace :load do task :defaults do set :rbenv_path, -> { From 6209582687c23695b4b0bec43fd8aec5949f53f2 Mon Sep 17 00:00:00 2001 From: Cyril Duchon-Doris Date: Wed, 12 Dec 2018 14:47:42 +0100 Subject: [PATCH 2/2] Fix silly mistakes --- README.md | 2 +- lib/capistrano/rbenv/without_hooks.rb | 2 +- lib/capistrano/tasks/deploy_rbenv.rake | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1c7be5f..7be1fb9 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ require capistrano/rbenv/without_hooks You can then add the hooks on a per deploy script basis ```ruby -# config/deploy/my_stage_with_nvm.rb +# config/deploy/my_stage_with_rbenv.rb Capistrano::DSL.stages.each do |stage| after stage, 'rbenv:validate' after stage, 'rbenv:map_bins' diff --git a/lib/capistrano/rbenv/without_hooks.rb b/lib/capistrano/rbenv/without_hooks.rb index ab310f0..b5997ca 100644 --- a/lib/capistrano/rbenv/without_hooks.rb +++ b/lib/capistrano/rbenv/without_hooks.rb @@ -1 +1 @@ -load File.expand_path('../../tasks/rbenv.cap', __FILE__) +load File.expand_path('../../tasks/rbenv.rake', __FILE__) diff --git a/lib/capistrano/tasks/deploy_rbenv.rake b/lib/capistrano/tasks/deploy_rbenv.rake index 499ff2f..33fadce 100644 --- a/lib/capistrano/tasks/deploy_rbenv.rake +++ b/lib/capistrano/tasks/deploy_rbenv.rake @@ -1,2 +1,2 @@ load File.expand_path('../rbenv.rake', __FILE__) -load File.expand_path('../../hooks/rbenv.cap', __FILE__) +load File.expand_path('../../hooks/rbenv.rb', __FILE__)