diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-03-09 13:26:23 -0300 |
---|---|---|
committer | Rafael França <rafaelmfranca@gmail.com> | 2016-03-09 13:26:23 -0300 |
commit | 20f2727ba4de36f8c98091340e8a89327013912f (patch) | |
tree | ea1ca288d3c3b0bda801fd71fd526f10a8cc9497 /railties/lib/rails/generators | |
parent | fe8239e35ad025fa833a9e8307d4f2b9f7d2978e (diff) | |
parent | 5c99a4b93e99cac2bc00fa79da6d79aa37582890 (diff) | |
download | rails-20f2727ba4de36f8c98091340e8a89327013912f.tar.gz rails-20f2727ba4de36f8c98091340e8a89327013912f.tar.bz2 rails-20f2727ba4de36f8c98091340e8a89327013912f.zip |
Merge pull request #24122 from claudiob/fix-23795
AppGenerator: allow both 'rake' and 'rails'
Diffstat (limited to 'railties/lib/rails/generators')
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 5fa487b78e..57309112b5 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -207,18 +207,23 @@ module Rails in_root { run_ruby_script("bin/rails generate #{what} #{argument}", verbose: false) } end - # Runs the supplied rake task + # Runs the supplied rake task (invoked with 'rake ...') # # rake("db:migrate") # rake("db:migrate", env: "production") # rake("gems:install", sudo: true) def rake(command, options={}) - log :rake, command - env = options[:env] || ENV["RAILS_ENV"] || 'development' - sudo = options[:sudo] && RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ ? 'sudo ' : '' - in_root { run("#{sudo}#{extify(:rails)} #{command} RAILS_ENV=#{env}", verbose: false) } + execute_command :rake, command, options + end + + # Runs the supplied rake task (invoked with 'rails ...') + # + # rails("db:migrate") + # rails("db:migrate", env: "production") + # rails("gems:install", sudo: true) + def rails_command(command, options={}) + execute_command :rails, command, options end - alias :rails_command :rake # Just run the capify command in root # @@ -271,6 +276,16 @@ module Rails end end + + # Runs the supplied command using either "rake ..." or "rails ..." + # based on the executor parameter provided. + def execute_command(executor, command, options={}) + log executor, command + env = options[:env] || ENV["RAILS_ENV"] || 'development' + sudo = options[:sudo] && RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ ? 'sudo ' : '' + in_root { run("#{sudo}#{extify(executor)} #{command} RAILS_ENV=#{env}", verbose: false) } + end + # Add an extension to the given name based on the platform. def extify(name) if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ |