aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorGannon McGibbon <gannon.mcgibbon@gmail.com>2019-01-23 17:24:52 -0500
committerGannon McGibbon <gannon.mcgibbon@gmail.com>2019-01-24 12:28:43 -0500
commita670654882063f0e89a5e450a16dc3cda2ed4030 (patch)
tree66b85fb7bafdce2bafa41bb96abf300d3696c454 /railties/lib
parent060fe164471213209de9637c19ee5c25492d0c1c (diff)
downloadrails-a670654882063f0e89a5e450a16dc3cda2ed4030.tar.gz
rails-a670654882063f0e89a5e450a16dc3cda2ed4030.tar.bz2
rails-a670654882063f0e89a5e450a16dc3cda2ed4030.zip
Fix deeply nested namespace command printing
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/rails/command/base.rb14
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