From 73aac26e9e15ee968b3d6debd83297de91c0a563 Mon Sep 17 00:00:00 2001 From: Adrian Marin Date: Thu, 19 Dec 2024 09:27:42 +0200 Subject: [PATCH 1/4] fix: ensure paths exist --- lib/hotwire/spark/file_watcher.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/hotwire/spark/file_watcher.rb b/lib/hotwire/spark/file_watcher.rb index 04be3fc7..5cf55742 100644 --- a/lib/hotwire/spark/file_watcher.rb +++ b/lib/hotwire/spark/file_watcher.rb @@ -25,7 +25,13 @@ def expand_path(path) end def paths - @callbacks_by_path.keys + ensure_paths_present @callbacks_by_path.keys + end + + def ensure_paths_present(paths) + paths.select do |path| + path.exist? + end end def process_changed_files(changed_files) From 2500c407306cc59b03f0c9b7f298a52cd2e4d669 Mon Sep 17 00:00:00 2001 From: Adrian Marin Date: Thu, 19 Dec 2024 09:33:44 +0200 Subject: [PATCH 2/4] we can even omit this check on boot time now --- lib/hotwire/spark/engine.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hotwire/spark/engine.rb b/lib/hotwire/spark/engine.rb index 677c3a9e..e05eadea 100644 --- a/lib/hotwire/spark/engine.rb +++ b/lib/hotwire/spark/engine.rb @@ -8,7 +8,7 @@ class Engine < ::Rails::Engine config.hotwire.spark = ActiveSupport::OrderedOptions.new config.hotwire.spark.merge! \ enabled: Rails.env.development?, - css_paths: File.directory?("app/assets/builds") ? %w[ app/assets/builds ] : %w[ app/assets/stylesheets ], + css_paths: %w[ app/assets/builds app/assets/stylesheets ], html_paths: %w[ app/controllers app/helpers app/models app/views ], stimulus_paths: %w[ app/javascript/controllers ] From 948bc20e806d7e9921614d3248f93d76c0eada7a Mon Sep 17 00:00:00 2001 From: Adrian Marin Date: Thu, 19 Dec 2024 12:30:07 +0200 Subject: [PATCH 3/4] only_existing_paths rename --- lib/hotwire/spark/file_watcher.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/hotwire/spark/file_watcher.rb b/lib/hotwire/spark/file_watcher.rb index 5cf55742..fea9bfee 100644 --- a/lib/hotwire/spark/file_watcher.rb +++ b/lib/hotwire/spark/file_watcher.rb @@ -25,10 +25,10 @@ def expand_path(path) end def paths - ensure_paths_present @callbacks_by_path.keys + only_existing_paths @callbacks_by_path.keys end - def ensure_paths_present(paths) + def only_existing_paths(paths) paths.select do |path| path.exist? end From e1c783684f13db55f7abaa708a69ffd795e24905 Mon Sep 17 00:00:00 2001 From: Adrian Marin Date: Thu, 19 Dec 2024 12:31:32 +0200 Subject: [PATCH 4/4] bring back bundling detection --- lib/hotwire/spark/engine.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hotwire/spark/engine.rb b/lib/hotwire/spark/engine.rb index e05eadea..677c3a9e 100644 --- a/lib/hotwire/spark/engine.rb +++ b/lib/hotwire/spark/engine.rb @@ -8,7 +8,7 @@ class Engine < ::Rails::Engine config.hotwire.spark = ActiveSupport::OrderedOptions.new config.hotwire.spark.merge! \ enabled: Rails.env.development?, - css_paths: %w[ app/assets/builds app/assets/stylesheets ], + css_paths: File.directory?("app/assets/builds") ? %w[ app/assets/builds ] : %w[ app/assets/stylesheets ], html_paths: %w[ app/controllers app/helpers app/models app/views ], stimulus_paths: %w[ app/javascript/controllers ]