mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Don't install webpacker if --skip-bundle or --skip-gemfile was given
This commit is contained in:
parent
249232f659
commit
5f92756977
2 changed files with 43 additions and 7 deletions
|
@ -405,11 +405,19 @@ module Rails
|
|||
end
|
||||
|
||||
def run_webpack
|
||||
if webpack_install?
|
||||
rails_command "webpacker:install"
|
||||
if options[:webpack] && options[:webpack] != "webpack"
|
||||
rails_command "webpacker:install:#{options[:webpack]}"
|
||||
end
|
||||
return unless webpack_install?
|
||||
|
||||
unless bundle_install?
|
||||
say <<~EXPLAIN
|
||||
Skipping `rails webpacker:install` because `bundle install` was skipped.
|
||||
To complete setup, you must run `bundle install` followed by `rails webpacker:install`.
|
||||
EXPLAIN
|
||||
return
|
||||
end
|
||||
|
||||
rails_command "webpacker:install"
|
||||
if options[:webpack] && options[:webpack] != "webpack"
|
||||
rails_command "webpacker:install:#{options[:webpack]}"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -107,12 +107,22 @@ class AppGeneratorTest < Rails::Generators::TestCase
|
|||
end
|
||||
|
||||
def test_skip_bundle
|
||||
generator([destination_root], skip_bundle: true, skip_webpack_install: true)
|
||||
run_generator_instance
|
||||
generator([destination_root], skip_bundle: true)
|
||||
output = run_generator_instance
|
||||
|
||||
assert_empty @bundle_commands
|
||||
# skip_bundle is only about running bundle install so ensure the Gemfile is still generated
|
||||
assert_file "Gemfile"
|
||||
assert_webpack_installation_skipped(output)
|
||||
end
|
||||
|
||||
def test_skip_gemfile
|
||||
generator([destination_root], skip_gemfile: true)
|
||||
output = run_generator_instance
|
||||
|
||||
assert_empty @bundle_commands
|
||||
assert_no_file "Gemfile"
|
||||
assert_webpack_installation_skipped(output)
|
||||
end
|
||||
|
||||
def test_assets
|
||||
|
@ -1264,4 +1274,22 @@ class AppGeneratorTest < Rails::Generators::TestCase
|
|||
assert_match(/^\s*# config\.file_watcher = ActiveSupport::EventedFileUpdateChecker/, content)
|
||||
end
|
||||
end
|
||||
|
||||
def assert_webpack_installation_skipped(output)
|
||||
assert_match(/^Skipping `rails webpacker:install`/, output)
|
||||
|
||||
%w(
|
||||
.browserslistrc
|
||||
babel.config.js
|
||||
bin/webpack
|
||||
bin/webpack-dev-server
|
||||
config/webpack
|
||||
config/webpack/development.js
|
||||
config/webpack/environment.js
|
||||
config/webpack/production.js
|
||||
config/webpack/test.js
|
||||
config/webpacker.yml
|
||||
postcss.config.js
|
||||
).each { |f| assert_no_file(f) }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue