be a bit more forgiving with reloader

This commit is contained in:
Sam 2015-02-27 17:19:30 +11:00
parent f555bbb416
commit b916108927

View file

@ -25,19 +25,22 @@ class Autospec::ReloadCss
def self.run_on_change(paths)
if paths.any? { |p| p =~ /\.(css|s[ac]ss)/ }
# todo connect to dev instead?
ActiveRecord::Base.establish_connection
s = DiscourseStylesheets.new(:desktop) # TODO: what about mobile?
s.compile
s.ensure_digestless_file
ActiveRecord::Base.clear_active_connections!
paths << "public" + s.stylesheet_relpath_no_digest
end
paths.map! do |p|
hash = nil
fullpath = "#{Rails.root}/#{p}"
hash = Digest::MD5.hexdigest(File.read(fullpath)) if File.exists?(fullpath)
p = p.sub /\.sass\.erb/, ""
p = p.sub /\.sass/, ""
p = p.sub /\.scss/, ""
p = p.sub /^app\/assets\/stylesheets/, "assets"
p = p.sub(/\.sass\.erb/, "")
p = p.sub(/\.sass/, "")
p = p.sub(/\.scss/, "")
p = p.sub(/^app\/assets\/stylesheets/, "assets")
{ name: p, hash: hash }
end
message_bus.publish "/file-change", paths