From e2fb5310d85cc52f760a644c4da3e0321f1c7818 Mon Sep 17 00:00:00 2001 From: Greg Kempe Date: Mon, 17 Nov 2014 16:46:58 +0200 Subject: [PATCH] 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. --- lib/sass/discourse_stylesheets.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/sass/discourse_stylesheets.rb b/lib/sass/discourse_stylesheets.rb index 028def076ef..ca0c5a9d63b 100644 --- a/lib/sass/discourse_stylesheets.rb +++ b/lib/sass/discourse_stylesheets.rb @@ -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