diff options
author | Yuji Yaginuma <yuuji.yaginuma@gmail.com> | 2016-12-09 12:07:40 +0900 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2016-12-08 19:07:40 -0800 |
commit | fbd33b911acd5a4487f37dc1df2aad439c090bfa (patch) | |
tree | e1765bcb2395cd9ca456194e14e8028a822238dd | |
parent | 81608cda9c0e3a3e70dc189481f68129ed74b8ba (diff) | |
download | rails-fbd33b911acd5a4487f37dc1df2aad439c090bfa.tar.gz rails-fbd33b911acd5a4487f37dc1df2aad439c090bfa.tar.bz2 rails-fbd33b911acd5a4487f37dc1df2aad439c090bfa.zip |
specify `skip_yarn` option in API-only Application (#27309)
-rw-r--r-- | railties/lib/rails/generators/rails/app/app_generator.rb | 10 | ||||
-rw-r--r-- | railties/test/generators/api_app_generator_test.rb | 5 |
2 files changed, 12 insertions, 3 deletions
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 20bc45fee8..a8586d56dd 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -186,9 +186,11 @@ module Rails raise Error, "Invalid value for --database option. Supported for preconfiguration are: #{DATABASES.join(", ")}." end - # Force sprockets to be skipped when generating API only apps. + # Force sprockets and yarn to be skipped when generating API only apps. # Can't modify options hash as it's frozen by default. - self.options = options.merge(skip_sprockets: true, skip_javascript: true).freeze if options[:api] + if options[:api] + self.options = options.merge(skip_sprockets: true, skip_javascript: true, skip_yarn: true).freeze + end end public_task :set_default_accessors! @@ -346,6 +348,10 @@ module Rails end end + def delete_bin_yarn_if_api_option + remove_file "bin/yarn" if options[:api] + end + def finish_template build(:leftovers) end diff --git a/railties/test/generators/api_app_generator_test.rb b/railties/test/generators/api_app_generator_test.rb index dc2872e45e..c54d9cc599 100644 --- a/railties/test/generators/api_app_generator_test.rb +++ b/railties/test/generators/api_app_generator_test.rb @@ -105,6 +105,7 @@ class ApiAppGeneratorTest < Rails::Generators::TestCase %w(app/assets app/helpers app/views/layouts/application.html.erb + bin/yarn config/initializers/assets.rb config/initializers/cookies_serializer.rb lib/assets @@ -115,6 +116,8 @@ class ApiAppGeneratorTest < Rails::Generators::TestCase public/500.html public/apple-touch-icon-precomposed.png public/apple-touch-icon.png - public/favicon.ico) + public/favicon.icon + vendor/package.json + ) end end |