Traverse symlinks to plugins in dev mode when compiling stylesheets

When developing plugins it's useful to symlink the to the plugin directory from the discourse directory, since that means the two are separate git repos.

However, Dir.glob doesn't by default traverse symlinks. This change means that the SASS compilation caching detects when any of a plugin's files have changed.
This commit is contained in:
Greg Kempe 2014-11-17 16:46:58 +02:00
parent 64b06b360a
commit e2fb5310d8
1 changed files with 11 additions and 4 deletions

View File

@ -56,10 +56,17 @@ class DiscourseStylesheets
end
def self.max_file_mtime
[ "#{Rails.root}/app/assets/stylesheets/**/*.*css",
"#{Rails.root}/plugins/**/*.*css",
"#{Rails.root}/plugins/**/plugin.rb" ].map do |pattern|
Dir.glob(pattern).map { |x| File.mtime(x) }.max
globs = ["#{Rails.root}/app/assets/stylesheets/**/*.*css"]
for path in (Discourse.plugins || []).map { |plugin| File.dirname(plugin.path) }
globs += [
"#{path}/plugin.rb",
"#{path}/**/*.*css",
]
end
globs.map do |pattern|
Dir.glob(pattern).map { |x| File.mtime(x) }.max
end.compact.max.to_i
end