Skip to content

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

DEV: ensures stylesheet watcher isn't crashing with gems plugins (#12733)

Joffrey JAFFEUX3157d5ee1b2f
diff --git a/lib/stylesheet/watcher.rb b/lib/stylesheet/watcher.rb
index f814d1b782d..a8bbda5f003 100644
--- a/lib/stylesheet/watcher.rb
+++ b/lib/stylesheet/watcher.rb
@@ -20,8 +20,14 @@ module Stylesheet
return @default_paths if @default_paths
@default_paths = ["app/assets/stylesheets"]
- Discourse.plugins.each do |p|
- @default_paths << File.dirname(p.path).sub(Rails.root.to_s, '').sub(/^\//, '')
+ Discourse.plugins.each do |plugin|
+ if plugin.path.to_s.include?(Rails.root.to_s)
+ @default_paths << File.dirname(plugin.path).sub(Rails.root.to_s, '').sub(/^\//, '')
+ else
+ # if plugin doesn’t seem to be in our app, consider it as outside of the app
+ # and ignore it
+ warn("[stylesheet watcher] Ignoring outside of rails root plugin: #{plugin.path.to_s}")
+ end
end
@default_paths
end