cbeer / engine_cart

Rake tasks to generate test applications for Rails Engines
MIT License
18 stars 16 forks source link

Fix parsing of ENGINE_CART_RAILS_OPTIONS #112

Closed jcoyne closed 2 years ago

jcoyne commented 2 years ago

The Rails::Generator::AppGenerator expects the arguments similar to how they would come from ARGV. This means we only need to split on spaces, there is no need to group options and values.

See https://github.com/rails/rails/blob/f95c0b7e96eb36bc3efc0c5beffbb9e84ea664e4/railties/lib/rails/commands/application/application_command.rb#L26-L28

This was preventing blacklight from testing using "-a propshaft"

cbeer commented 2 years ago

Will this cause trouble if one of the option values have spaces? I'm eyeing these arguments that take paths:

  -r, [--ruby=PATH]                                          # Path to the Ruby binary of your choice
  -m, [--template=TEMPLATE]                                  # Path to some application template (can be a filesystem path or URL)
      [--rc=RC]                                              # Path to file containing extra configuration options for rails command
jcoyne commented 2 years ago

I don't think so. This is how ARGV, would handle them

cbeer commented 2 years ago

Is it?

18:40 % cat a.rb 
puts ARGV.inspect
18:40 % ruby a.rb "multi word arg in quotes"
["multi word arg in quotes"]
18:40 % ruby a.rb multi  arg 
["multi", "arg"]
jcoyne commented 2 years ago

Oh, right, I neglected to think about that case.

jcoyne commented 2 years ago

Shellwords.shellwords is what we need.