Skip to content

A platform for community discussion. Free, open, simple.

DEV: Automatically reload dev when symlinked plugins change (#32073)

Gary Pendergast4a92b0afd8fb
diff --git a/config/initializers/000-development_reload_warnings.rb b/config/initializers/000-development_reload_warnings.rb
index 78f5661b3c6..31b512e1378 100644
--- a/config/initializers/000-development_reload_warnings.rb
+++ b/config/initializers/000-development_reload_warnings.rb
@@ -11,6 +11,12 @@ if Rails.env.development? && !Rails.configuration.cache_classes && Discourse.run
"#{Rails.root}/plugins",
]
+ # Find symlinked plugins, and add their real paths to the watch list.
+ paths +=
+ Dir["#{Rails.root}/plugins/*"]
+ .select { |path| File.symlink? path }
+ .map { |path| File.expand_path(File.readlink(path), File.dirname(path)) }
+
if Listen::Adapter::Linux.usable?
# The Listen gem watches recursively, which has a cost per-file on Linux (via rb-inotify)
# Skip a bunch of unnecessary directories to reduce the cost