Browse Source

before_reload

main
pvincent 5 months ago
parent
commit
0091b4df87
  1. 15
      lib/monkey_patches/rails_live_reload/watcher.rb

15
lib/monkey_patches/rails_live_reload/watcher.rb

@ -3,16 +3,15 @@ module RailsLiveReload
class Watcher class Watcher
ENV_FILE = Rails.root.join('.env').to_s ENV_FILE = Rails.root.join('.env').to_s
def reload_all def reload_all
data = {
event: RailsLiveReload::INTERNAL[:socket_events][:reload],
files:
}.to_json
before_reload(files)
data = { event: RailsLiveReload::INTERNAL[:socket_events][:reload], files: }.to_json
@sockets.each { |socket, _| socket.puts data } # rubocop:disable Style/HashEachMethods
end
LiveConstants.reload! if files.find { |change| change[0] == ENV_FILE }
private
@sockets.each do |socket, _|
socket.puts data
end
def before_reload(files)
LiveConstants.reload! if files.find { |change| change[0] == ENV_FILE }
end end
end end
end end
Loading…
Cancel
Save