From 0a5d479fd12ac59a939789543eae8be8bf94ec63 Mon Sep 17 00:00:00 2001 From: Kir Shatrov Date: Tue, 19 Nov 2013 11:05:48 +0400 Subject: [PATCH] Prepare command with `bundle exec` using SSH prefixes --- README.md | 8 ++++++++ lib/capistrano/tasks/bundler.cap | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fca697c6..1dd17046 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,14 @@ Configurable options, shown here with defaults: set :bundle_binstubs, -> { shared_path.join('bin') } set :bundle_roles, :all +By default, this integrations adds `bundle exec` prefix to common executables like `rake`, `ruby` and `rails`. + +If you want to use `bundle exec` prefix with other executables, you can do it with setting: + +```ruby +set :bundle_bins, %w(ruby rake rails any_other_executable) +``` + ## Contributing 1. Fork it diff --git a/lib/capistrano/tasks/bundler.cap b/lib/capistrano/tasks/bundler.cap index 729a13f6..b58faf7c 100644 --- a/lib/capistrano/tasks/bundler.cap +++ b/lib/capistrano/tasks/bundler.cap @@ -26,7 +26,14 @@ namespace :bundler do end end - before 'deploy:updated', 'bundler:install' + task :map_bins do + fetch(:bundle_bins).each do |command| + SSHKit.config.command_map.prefix[command.to_sym].push("bundle exec") + end + end + + before 'deploy:starting', 'bundler:map_bins' + before 'deploy:updated', 'bundler:install' end namespace :load do @@ -37,5 +44,6 @@ namespace :load do set :bundle_without, %w{development test}.join(' ') set :bundle_binstubs, -> { shared_path.join('bin') } set :bundle_roles, :all + set :bundle_bins, %w(ruby rake rails) end end