Skip to content

Commit

Permalink
Merge pull request #2550 from jekyll/extract-watch
Browse files Browse the repository at this point in the history
  • Loading branch information
parkr committed Jun 27, 2014
2 parents 2c63608 + c239746 commit 0c8fc63
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 35 deletions.
2 changes: 1 addition & 1 deletion jekyll.gemspec
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
34 changes: 2 additions & 32 deletions lib/jekyll/commands/build.rb
Expand Up @@ -58,38 +58,8 @@ def build(site, options)
#
# 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
Expand Down
5 changes: 3 additions & 2 deletions site/docs/continuous-integration.md
Expand Up @@ -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
Expand Down

0 comments on commit 0c8fc63

Please sign in to comment.