diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d7240f05..07cdeb2dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Changes since last non-beta release. _Please add entries here for your pull requests that are not yet released._ +- Fix commands execution for projects with space in absolute path [PR 322](https://github.com/shakacode/shakapacker/pull/322) by [kukicola](https://github.com/kukicola). ### Fixed - Fixed creation of assets:precompile if it is missing [PR 325](https://github.com/shakacode/shakapacker/pull/325) by [ahangarha](https://github.com/ahangarha). diff --git a/lib/shakapacker/compiler.rb b/lib/shakapacker/compiler.rb index f5d3997f1..4e95a38f4 100644 --- a/lib/shakapacker/compiler.rb +++ b/lib/shakapacker/compiler.rb @@ -82,7 +82,7 @@ def run_webpack stdout, stderr, status = Open3.capture3( webpack_env, - "#{optionalRubyRunner} #{bin_shakapacker_path}", + "#{optionalRubyRunner} '#{bin_shakapacker_path}'", chdir: File.expand_path(config.root_path) ) diff --git a/lib/shakapacker/utils/misc.rb b/lib/shakapacker/utils/misc.rb index b7f8d2d36..c46f60947 100644 --- a/lib/shakapacker/utils/misc.rb +++ b/lib/shakapacker/utils/misc.rb @@ -29,7 +29,7 @@ def self.object_to_boolean(value) # Executes a string or an array of strings in a shell in the given directory in an unbundled environment def self.sh_in_dir(dir, *shell_commands) - shell_commands.flatten.each { |shell_command| sh %(cd #{dir} && #{shell_command.strip}) } + shell_commands.flatten.each { |shell_command| sh %(cd '#{dir}' && #{shell_command.strip}) } end end end diff --git a/lib/tasks/shakapacker/binstubs.rake b/lib/tasks/shakapacker/binstubs.rake index 44a08a069..4a32f49a5 100644 --- a/lib/tasks/shakapacker/binstubs.rake +++ b/lib/tasks/shakapacker/binstubs.rake @@ -7,9 +7,9 @@ namespace :shakapacker do prefix = task.name.split(/#|shakapacker:binstubs/).first if Rails::VERSION::MAJOR >= 5 - exec "#{RbConfig.ruby} #{bin_path}/rails #{prefix}app:template LOCATION='#{binstubs_template_path}'" + exec "#{RbConfig.ruby} '#{bin_path}/rails' #{prefix}app:template LOCATION='#{binstubs_template_path}'" else - exec "#{RbConfig.ruby} #{bin_path}/rake #{prefix}rails:template LOCATION='#{binstubs_template_path}'" + exec "#{RbConfig.ruby} '#{bin_path}/rake' #{prefix}rails:template LOCATION='#{binstubs_template_path}'" end end end diff --git a/lib/tasks/shakapacker/install.rake b/lib/tasks/shakapacker/install.rake index 78f2ca74e..04aa19a1f 100644 --- a/lib/tasks/shakapacker/install.rake +++ b/lib/tasks/shakapacker/install.rake @@ -9,9 +9,9 @@ namespace :shakapacker do prefix = task.name.split(/#|shakapacker:install/).first if Rails::VERSION::MAJOR >= 5 - exec "#{RbConfig.ruby} #{bin_path}/rails #{prefix}app:template LOCATION='#{install_template_path}'" + exec "#{RbConfig.ruby} '#{bin_path}/rails' #{prefix}app:template LOCATION='#{install_template_path}'" else - exec "#{RbConfig.ruby} #{bin_path}/rake #{prefix}rails:template LOCATION='#{install_template_path}'" + exec "#{RbConfig.ruby} '#{bin_path}/rake' #{prefix}rails:template LOCATION='#{install_template_path}'" end end end diff --git a/spec/generator_specs/generator_spec.rb b/spec/generator_specs/generator_spec.rb index 3ed7a738f..99a78adaf 100644 --- a/spec/generator_specs/generator_spec.rb +++ b/spec/generator_specs/generator_spec.rb @@ -33,7 +33,7 @@ describe "shakapacker:install" do context "in a normal Rails project" do before :all do - sh_in_dir(SPEC_PATH, "cp -r #{BASE_RAILS_APP_PATH} #{TEMP_RAILS_APP_PATH}") + sh_in_dir(SPEC_PATH, "cp -r '#{BASE_RAILS_APP_PATH}' '#{TEMP_RAILS_APP_PATH}'") Bundler.with_unbundled_env do sh_in_dir(TEMP_RAILS_APP_PATH, "FORCE=true bundle exec rails shakapacker:install")