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

* DEV: ensures stylesheet watcher isn't crashing with gems plugins

This bug has been exhibited since discourse_dev is now including an auth plugin which was loaded as a relative path instead of an absolute path, eg:

`Users/bob/.gem/ruby/2.6.6/gems/discourse_dev-0.1.0/auth/plugin.rb`

Instead of

`/Users/bob/.gem/ruby/2.6.6/gems/discourse_dev-0.1.0/auth/plugin.rb`
This commit is contained in:
Joffrey JAFFEUX 2021-04-16 15:25:20 +02:00 committed by GitHub
parent eb7145d5a4
commit 3157d5ee1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -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 doesnt 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