Permalink
Browse files

Merge pull request #31485 from y-yagi/skip_bootsnap_option

Add `skip_bootsnap` option
  • Loading branch information...
eileencodes committed Dec 18, 2017
2 parents 6553c7f + 838b40d commit ce2fc70c7bd5d1f57c783d0799d36ee798115513
@@ -84,6 +84,9 @@ def self.add_shared_options_for(name)
class_option :skip_system_test, type: :boolean, default: false,
desc: "Skip system test files"
class_option :skip_bootsnap, type: :boolean, default: false,
desc: "Skip bootsnap gem"
class_option :dev, type: :boolean, default: false,
desc: "Setup the #{name} with Gemfile pointing to your Rails checkout"
@@ -435,6 +438,10 @@ def depend_on_listen?
!options[:skip_listen] && os_supports_listen_out_of_the_box?
end
def depend_on_bootsnap?
!options[:skip_bootsnap]
end
def os_supports_listen_out_of_the_box?
RbConfig::CONFIG["host_os"] =~ /darwin|linux/
end
@@ -29,9 +29,11 @@ ruby <%= "'#{RUBY_VERSION}'" -%>
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
<% if depend_on_bootsnap? -%>
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
<%- end -%>
<%- if options.api? -%>
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
# gem 'rack-cors'
@@ -1,7 +1,9 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
<% if depend_on_bootsnap? -%>
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
<%- end -%>
if %w[s server c console].any? { |a| ARGV.include?(a) }
puts "=> Booting Rails"
@@ -792,6 +792,26 @@ def test_generator_if_skip_turbolinks_is_given
end
end
def test_bootsnap
run_generator
assert_gem "bootsnap"
assert_file "config/boot.rb" do |content|
assert_match(/require 'bootsnap\/setup'/, content)
end
end
def test_skip_bootsnap
run_generator [destination_root, "--skip-bootsnap"]
assert_file "Gemfile" do |content|
assert_no_match(/bootsnap/, content)
end
assert_file "config/boot.rb" do |content|
assert_no_match(/require 'bootsnap\/setup'/, content)
end
end
def test_inclusion_of_ruby_version
run_generator

0 comments on commit ce2fc70

Please sign in to comment.