Module: Jekyll::Watcher
Instance Method Summary collapse
-
#watch(options, site = nil) ⇒ Object
Public: Continuously watch for file changes and rebuild the site whenever a change is detected.
Instance Method Details
#watch(options, site = nil) ⇒ Object
Public: Continuously watch for file changes and rebuild the site whenever a change is detected.
If the optional site argument is populated, that site instance will be reused and the options Hash ignored. Otherwise, a new site instance will be instantiated from the options Hash and used.
options - A Hash containing the site configuration site - The current site instance (populated starting with Jekyll 3.2)
(optional, default: nil)
Returns nothing.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/jekyll/watcher.rb', line 21 def watch(, site = nil) ENV["LISTEN_GEM_DEBUGGING"] ||= "1" if ["verbose"] site ||= Jekyll::Site.new() listener = build_listener(site, ) listener.start Jekyll.logger.info "Auto-regeneration:", "enabled for '#{["source"]}'" unless ["serving"] trap("INT") do listener.stop puts " Halting auto-regeneration." exit 0 end sleep_forever end rescue ThreadError # You pressed Ctrl-C, oh my! end |