Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support spaces in app path #322

Merged
merged 3 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
ahangarha marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion lib/shakapacker/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

Expand Down
2 changes: 1 addition & 1 deletion lib/shakapacker/utils/misc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/shakapacker/binstubs.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions lib/tasks/shakapacker/install.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/generator_specs/generator_spec.rb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to support spaces in the path for tests, there are more cases to be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests are currently passing, only this one had any issues

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough
@justin808 This PR looks good to me.

Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down