Merge pull request #2550 from jekyll/extract-watch
This commit is contained in:
commit
0c8fc63b33
|
@ -30,7 +30,6 @@ Gem::Specification.new do |s|
|
|||
|
||||
s.add_runtime_dependency('liquid', "~> 2.6.1")
|
||||
s.add_runtime_dependency('classifier', "~> 1.3")
|
||||
s.add_runtime_dependency('listen', [">= 2.7.6", "< 3.0.0"])
|
||||
s.add_runtime_dependency('kramdown', "~> 1.3")
|
||||
s.add_runtime_dependency('pygments.rb', "~> 0.6.0")
|
||||
s.add_runtime_dependency('mercenary', "~> 0.3.3")
|
||||
|
@ -42,6 +41,7 @@ Gem::Specification.new do |s|
|
|||
s.add_runtime_dependency('jekyll-gist', '~> 1.0')
|
||||
s.add_runtime_dependency('jekyll-coffeescript', '~> 1.0')
|
||||
s.add_runtime_dependency('jekyll-sass-converter', '~> 1.0')
|
||||
s.add_runtime_dependency('jekyll-watch', '~> 1.0.0.rc2')
|
||||
|
||||
s.add_development_dependency('rake', "~> 10.1")
|
||||
s.add_development_dependency('rdoc', "~> 3.11")
|
||||
|
|
|
@ -58,38 +58,8 @@ module Jekyll
|
|||
#
|
||||
# Returns nothing.
|
||||
def watch(site, options)
|
||||
require 'listen'
|
||||
|
||||
listener = Listen.to(
|
||||
options['source'],
|
||||
:ignore => ignore_paths(options),
|
||||
:force_polling => options['force_polling']
|
||||
) do |modified, added, removed|
|
||||
t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
||||
n = modified.length + added.length + removed.length
|
||||
print Jekyll.logger.formatted_topic("Regenerating:") + "#{n} files at #{t} "
|
||||
begin
|
||||
process_site(site)
|
||||
puts "...done."
|
||||
rescue => e
|
||||
puts "...error:"
|
||||
Jekyll.logger.warn "Error:", e.message
|
||||
Jekyll.logger.warn "Error:", "Run jekyll build --trace for more information."
|
||||
end
|
||||
end
|
||||
listener.start
|
||||
|
||||
Jekyll.logger.info "Auto-regeneration:", "enabled for '#{options['source']}'"
|
||||
|
||||
unless options['serving']
|
||||
trap("INT") do
|
||||
listener.stop
|
||||
puts " Halting auto-regeneration."
|
||||
exit 0
|
||||
end
|
||||
|
||||
loop { sleep 1000 }
|
||||
end
|
||||
require 'jekyll-watch'
|
||||
Jekyll::Commands::Watch.watch(site, options)
|
||||
end
|
||||
|
||||
end # end of class << self
|
||||
|
|
|
@ -40,9 +40,10 @@ or write a Ruby script which utilizes the gem.
|
|||
|
||||
{% highlight bash %}
|
||||
#!/usr/bin/env bash
|
||||
set -e # halt script on error
|
||||
|
||||
jekyll build
|
||||
htmlproof ./_site
|
||||
bundle exec jekyll build
|
||||
bundle exec htmlproof ./_site
|
||||
{% endhighlight %}
|
||||
|
||||
Some options can be specified via command-line switches. Check out the
|
||||
|
|
Loading…
Reference in New Issue