Class: ReactOnRails::TestHelper::EnsureAssetsCompiled
- Inherits:
-
Object
- Object
- ReactOnRails::TestHelper::EnsureAssetsCompiled
- Defined in:
- lib/react_on_rails/test_helper/ensure_assets_compiled.rb
Class Attribute Summary collapse
-
.has_been_run ⇒ Object
Returns the value of attribute has_been_run.
Instance Attribute Summary collapse
-
#webpack_assets_compiler ⇒ Object
readonly
Returns the value of attribute webpack_assets_compiler.
-
#webpack_assets_status_checker ⇒ Object
readonly
Returns the value of attribute webpack_assets_status_checker.
Instance Method Summary collapse
-
#call ⇒ Object
Several Scenarios: 1.
-
#initialize(webpack_assets_status_checker: nil, webpack_assets_compiler: nil) ⇒ EnsureAssetsCompiled
constructor
A new instance of EnsureAssetsCompiled.
- #puts_start_compile_check_message(stale_files) ⇒ Object
Constructor Details
#initialize(webpack_assets_status_checker: nil, webpack_assets_compiler: nil) ⇒ EnsureAssetsCompiled
Returns a new instance of EnsureAssetsCompiled.
15 16 17 18 19 |
# File 'lib/react_on_rails/test_helper/ensure_assets_compiled.rb', line 15 def initialize(webpack_assets_status_checker: nil, webpack_assets_compiler: nil) @webpack_assets_status_checker = webpack_assets_status_checker @webpack_assets_compiler = webpack_assets_compiler end |
Class Attribute Details
.has_been_run ⇒ Object
Returns the value of attribute has_been_run.
7 8 9 |
# File 'lib/react_on_rails/test_helper/ensure_assets_compiled.rb', line 7 def has_been_run @has_been_run end |
Instance Attribute Details
#webpack_assets_compiler ⇒ Object (readonly)
Returns the value of attribute webpack_assets_compiler.
12 13 14 |
# File 'lib/react_on_rails/test_helper/ensure_assets_compiled.rb', line 12 def webpack_assets_compiler @webpack_assets_compiler end |
#webpack_assets_status_checker ⇒ Object (readonly)
Returns the value of attribute webpack_assets_status_checker.
12 13 14 |
# File 'lib/react_on_rails/test_helper/ensure_assets_compiled.rb', line 12 def webpack_assets_status_checker @webpack_assets_status_checker end |
Instance Method Details
#call ⇒ Object
Several Scenarios:
-
No webpack watch processes for static assets and files are mising or out of date.
-
Only webpack watch process for server bundle as we’re the hot reloading setup.
-
For whatever reason, the watch processes are running, but some clean script removed the generated bundles.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/react_on_rails/test_helper/ensure_assets_compiled.rb', line 26 def call # Only check this ONCE during a test run return if self.class.has_been_run # Be sure we don't do this again. self.class.has_been_run = true ReactOnRails::Locales.compile stale_gen_files = webpack_assets_status_checker.stale_generated_webpack_files # All done if no stale files! return if stale_gen_files.empty? ReactOnRails::PacksGenerator.instance.generate_packs_if_stale if ReactOnRails.configuration.auto_load_bundle # Inform the developer that we're ensuring gen assets are ready. (stale_gen_files) webpack_assets_compiler.compile_assets end |
#puts_start_compile_check_message(stale_files) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/react_on_rails/test_helper/ensure_assets_compiled.rb', line 48 def (stale_files) puts "\n Detected the following stale generated files:\n \#{stale_files.join(\"\\n \")}\n\n React on Rails will ensure your JavaScript generated files are up to date, using your\n `\#{ReactOnRails::Utils.prepend_cd_node_modules_directory(ReactOnRails.configuration.build_test_command)}` command.\n\n MSG\nend\n" |