2010-09-21 21:30:17 -04:00
|
|
|
module Middleman::Features::LiveReload
|
|
|
|
class << self
|
|
|
|
def registered(app)
|
|
|
|
return unless Middleman::Server.environment == :development
|
|
|
|
|
|
|
|
begin
|
|
|
|
require 'livereload'
|
|
|
|
rescue LoadError
|
|
|
|
puts "Livereload not available. Install it with: gem install livereload"
|
|
|
|
end
|
|
|
|
|
|
|
|
new_config = ::LiveReload::Config.new do |config|
|
2011-06-05 15:44:57 -04:00
|
|
|
::Tilt.mappings.each do |key, v|
|
|
|
|
config.exts << key
|
|
|
|
end
|
2010-09-21 21:30:17 -04:00
|
|
|
end
|
2011-06-05 15:44:57 -04:00
|
|
|
|
|
|
|
pid = fork {
|
|
|
|
require 'livereload'
|
|
|
|
::LiveReload.run [Middleman::Server.views], new_config
|
|
|
|
}
|
2010-09-21 21:30:17 -04:00
|
|
|
|
|
|
|
end
|
|
|
|
alias :included :registered
|
|
|
|
end
|
|
|
|
end
|