From c2d5d2ea5a11ce4b5c41ef186d4dbf9806f808dd Mon Sep 17 00:00:00 2001 From: Watson Date: Fri, 28 Nov 2014 15:12:44 +0900 Subject: [PATCH] [RM-644] install bundled gem and run "bundle exec" for extension --- lib/motion/project/target/extension_target.rb | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/motion/project/target/extension_target.rb b/lib/motion/project/target/extension_target.rb index c1a929ab..f88d3cc1 100644 --- a/lib/motion/project/target/extension_target.rb +++ b/lib/motion/project/target/extension_target.rb @@ -50,12 +50,22 @@ module Motion; module Project # @return [Boolean] Whether or not invoking the rake task succeeded. # def rake(task) - command = "cd #{@full_path} && #{environment_variables} rake #{task}" - if App::VERBOSE - command << " --trace" - puts command + Dir.chdir(@full_path) do + ENV["PWD"] = @full_path + rake = "rake" + if File.exist?("Gemfile") + ENV["BUNDLE_GEMFILE"] = File.join(@full_path, "Gemfile") + system(ENV, "bundle install") unless File.exist?("Gemfile.lock") + rake = "bundle exec rake" + end + + command = "#{environment_variables} #{rake} #{task}" + if App::VERBOSE + command << " --trace" + puts command + end + system(ENV, command) end - system(command) end def build(platform)