Skip to content

Commit

Permalink
Raise more helpful error when current_release path cannot be successf…
Browse files Browse the repository at this point in the history
…ully detected.
  • Loading branch information
nextmat committed Sep 13, 2011
1 parent 9f80959 commit 7045452
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/bundler/deployment.rb
Expand Up @@ -4,9 +4,11 @@ def self.define_task(context, task_method = :task, opts = {})
if defined?(Capistrano) && context.is_a?(Capistrano::Configuration)
context_name = "capistrano"
role_default = "{:except => {:no_release => true}}"
error_type = ::Capistrano::CommandError
else
context_name = "vlad"
role_default = "[:app]"
error_type = ::Rake::CommandFailedError
end

roles = context.fetch(:bundle_roles, false)
Expand Down Expand Up @@ -39,13 +41,16 @@ def self.define_task(context, task_method = :task, opts = {})
bundle_dir = context.fetch(:bundle_dir, File.join(context.fetch(:shared_path), 'bundle'))
bundle_gemfile = context.fetch(:bundle_gemfile, "Gemfile")
bundle_without = [*context.fetch(:bundle_without, [:development, :test])].compact

args = ["--gemfile #{File.join(context.fetch(:current_release), bundle_gemfile)}"]
current_release = context.fetch(:current_release)
if current_release.to_s.empty?
raise error_type.new("Cannot detect current release path - make sure you have deployed at least once.")
end
args = ["--gemfile #{File.join(current_release, bundle_gemfile)}"]
args << "--path #{bundle_dir}" unless bundle_dir.to_s.empty?
args << bundle_flags.to_s
args << "--without #{bundle_without.join(" ")}" unless bundle_without.empty?

run "cd #{context.fetch(:current_release)} && #{bundle_cmd} install #{args.join(' ')}"
run "cd #{current_release} && #{bundle_cmd} install #{args.join(' ')}"
end
end
end
Expand Down

0 comments on commit 7045452

Please sign in to comment.