mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
be a bit more forgiving with reloader
This commit is contained in:
parent
f555bbb416
commit
b916108927
1 changed files with 7 additions and 4 deletions
|
@ -25,19 +25,22 @@ class Autospec::ReloadCss
|
||||||
|
|
||||||
def self.run_on_change(paths)
|
def self.run_on_change(paths)
|
||||||
if paths.any? { |p| p =~ /\.(css|s[ac]ss)/ }
|
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 = DiscourseStylesheets.new(:desktop) # TODO: what about mobile?
|
||||||
s.compile
|
s.compile
|
||||||
s.ensure_digestless_file
|
s.ensure_digestless_file
|
||||||
|
ActiveRecord::Base.clear_active_connections!
|
||||||
paths << "public" + s.stylesheet_relpath_no_digest
|
paths << "public" + s.stylesheet_relpath_no_digest
|
||||||
end
|
end
|
||||||
paths.map! do |p|
|
paths.map! do |p|
|
||||||
hash = nil
|
hash = nil
|
||||||
fullpath = "#{Rails.root}/#{p}"
|
fullpath = "#{Rails.root}/#{p}"
|
||||||
hash = Digest::MD5.hexdigest(File.read(fullpath)) if File.exists?(fullpath)
|
hash = Digest::MD5.hexdigest(File.read(fullpath)) if File.exists?(fullpath)
|
||||||
p = p.sub /\.sass\.erb/, ""
|
p = p.sub(/\.sass\.erb/, "")
|
||||||
p = p.sub /\.sass/, ""
|
p = p.sub(/\.sass/, "")
|
||||||
p = p.sub /\.scss/, ""
|
p = p.sub(/\.scss/, "")
|
||||||
p = p.sub /^app\/assets\/stylesheets/, "assets"
|
p = p.sub(/^app\/assets\/stylesheets/, "assets")
|
||||||
{ name: p, hash: hash }
|
{ name: p, hash: hash }
|
||||||
end
|
end
|
||||||
message_bus.publish "/file-change", paths
|
message_bus.publish "/file-change", paths
|
||||||
|
|
Loading…
Reference in a new issue