Skip to content

Commit

Permalink
Show a reloading log for Roda routes in the server folder (#818)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredcwhite authored Oct 23, 2023
1 parent 551eb53 commit b5f8622
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions bridgetown-core/lib/bridgetown-core/rack/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def self.boot(*)
end

# @param root [String] root of Bridgetown site, defaults to config value
def self.autoload_server_folder( # rubocop:todo Metrics/MethodLength
def self.autoload_server_folder( # rubocop:todo Metrics
root: Bridgetown::Current.preloaded_configuration.root_dir
)
server_folder = File.join(root, "server")
Expand All @@ -62,7 +62,18 @@ def self.autoload_server_folder( # rubocop:todo Metrics/MethodLength
loader.do_not_eager_load(File.join(server_folder, "roda_app.rb"))

unless ENV["BRIDGETOWN_ENV"] == "production"
Listen.to(server_folder) do |_modified, _added, _removed|
Listen.to(server_folder) do |modified, added, removed|
c = modified + added + removed
n = c.length

Bridgetown.logger.info(
"Reloading…",
"#{n} file#{"s" if n > 1} changed at #{Time.now.strftime("%Y-%m-%d %H:%M:%S")}"
)
c.each do |path|
Bridgetown.logger.info "", "- #{path["#{File.dirname(server_folder)}/".length..]}"
end

loader.reload
loader.eager_load
Bridgetown::Rack::Routes.reload_subclasses
Expand Down

0 comments on commit b5f8622

Please sign in to comment.