diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2019-01-24 13:13:10 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-24 13:13:10 -0500 |
commit | 1e25dfde032172bab2b126e60fac0302025defcc (patch) | |
tree | 0b4368251a6e282ea89f1d3a5f9848dae1048fa1 /railties/lib/rails | |
parent | c1e949e9e618f75dc446ffa584c3b441c48714b1 (diff) | |
parent | a670654882063f0e89a5e450a16dc3cda2ed4030 (diff) | |
download | rails-1e25dfde032172bab2b126e60fac0302025defcc.tar.gz rails-1e25dfde032172bab2b126e60fac0302025defcc.tar.bz2 rails-1e25dfde032172bab2b126e60fac0302025defcc.zip |
Merge pull request #35033 from gmcgibbon/multilevel_command_root_namespace
Fix deeply nested namespace command printing
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/command/base.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/railties/lib/rails/command/base.rb b/railties/lib/rails/command/base.rb index 766872de8a..a22b198c66 100644 --- a/railties/lib/rails/command/base.rb +++ b/railties/lib/rails/command/base.rb @@ -115,7 +115,7 @@ module Rails # For a Rails::Command::TestCommand placed in <tt>rails/command/test_command.rb</tt> # would return <tt>rails/test</tt>. def default_command_root - path = File.expand_path(File.join("../commands", command_root_namespace), __dir__) + path = File.expand_path(relative_command_path, __dir__) path if File.exist?(path) end @@ -135,12 +135,20 @@ module Rails end def command_root_namespace - (namespace.split(":") - %w( rails )).first + (namespace.split(":") - %w(rails)).join(":") + end + + def relative_command_path + File.join("../commands", *command_root_namespace.split(":")) end def namespaced_commands commands.keys.map do |key| - key == command_root_namespace ? key : "#{command_root_namespace}:#{key}" + if command_root_namespace.match?(/(\A|\:)#{key}\z/) + command_root_namespace + else + "#{command_root_namespace}:#{key}" + end end end end |