mirror of https://github.com/rails/rails
Add `skip-webpack-install` option
This option is useful when want to check only the files generated by `rails new`, or if want to do something before `webpacker:install`.
This commit is contained in:
parent
a1ee4a9ff9
commit
bd0ca39564
|
@ -399,6 +399,10 @@ module Rails
|
|||
!options[:skip_spring] && !options.dev? && Process.respond_to?(:fork) && !RUBY_PLATFORM.include?("cygwin")
|
||||
end
|
||||
|
||||
def webpack_install?
|
||||
!(options[:skip_javascript] || options[:skip_webpack_install])
|
||||
end
|
||||
|
||||
def depends_on_system_test?
|
||||
!(options[:skip_system_test] || options[:skip_test] || options[:api])
|
||||
end
|
||||
|
@ -420,7 +424,7 @@ module Rails
|
|||
end
|
||||
|
||||
def run_webpack
|
||||
unless options[:skip_javascript]
|
||||
if webpack_install?
|
||||
rails_command "webpacker:install"
|
||||
rails_command "webpacker:install:#{options[:webpack]}" if options[:webpack] && options[:webpack] != "webpack"
|
||||
end
|
||||
|
|
|
@ -261,6 +261,9 @@ module Rails
|
|||
class_option :webpack, type: :string, default: nil,
|
||||
desc: "Preconfigure Webpack with a particular framework (options: #{WEBPACKS.join('/')})"
|
||||
|
||||
class_option :skip_webpack_install, type: :boolean, default: false,
|
||||
desc: "Don't run Webpack install"
|
||||
|
||||
def initialize(*args)
|
||||
super
|
||||
|
||||
|
|
|
@ -825,6 +825,20 @@ class AppGeneratorTest < Rails::Generators::TestCase
|
|||
assert_gem "webpacker"
|
||||
end
|
||||
|
||||
def test_skip_webpack_install
|
||||
command_check = -> command do
|
||||
if command == "webpacker:install"
|
||||
assert false, "webpacker:install expected not to be called."
|
||||
end
|
||||
end
|
||||
|
||||
generator([destination_root], skip_webpack_install: true).stub(:rails_command, command_check) do
|
||||
quietly { generator.invoke_all }
|
||||
end
|
||||
|
||||
assert_gem "webpacker"
|
||||
end
|
||||
|
||||
def test_generator_if_skip_turbolinks_is_given
|
||||
run_generator [destination_root, "--skip-turbolinks", "--no-skip-javascript"]
|
||||
|
||||
|
|
Loading…
Reference in New Issue