Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Livereload sleep #68

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/jekyll/watcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def watch(options, site = nil)
listener.start

Jekyll.logger.info "Auto-regeneration:", "enabled for '#{options["source"]}'"
if options["livereload_sleep"]
Jekyll.logger.info "LiveReload:", "auto-regeneration delayed "\
"#{options["livereload_sleep"]} second(s)"
end

unless options["serving"]
trap("INT") do
Expand All @@ -44,8 +48,9 @@ def watch(options, site = nil)
def build_listener(site, options)
Listen.to(
options["source"],
:ignore => listen_ignore_paths(options),
:force_polling => options["force_polling"],
:ignore => listen_ignore_paths(options),
:force_polling => options["force_polling"],
:wait_for_delay => options["livereload_sleep"],
&listen_handler(site)
)
end
Expand Down
13 changes: 11 additions & 2 deletions spec/watcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
let(:listener) { instance_double(Listen::Listener) }

let(:opts) do
{ :ignore => default_ignored, :force_polling => options["force_polling"] }
{ :ignore => default_ignored, :force_polling => options["force_polling"],
:wait_for_delay => options["livereload_sleep"], }
end

before do
Expand Down Expand Up @@ -62,6 +63,12 @@
.with(anything, hash_including(:force_polling => nil))
end

it "defaults to no livereload_sleep" do
expect(Listen)
.to have_received(:to)
.with(anything, hash_including(:wait_for_delay => nil))
end

context "with force_polling turned on" do
let(:options) { base_opts.merge("force_polling" => true) }

Expand All @@ -76,7 +83,9 @@
describe "#watch using site instance" do
let(:listener) { instance_double(Listen::Listener) }

let(:opts) { { :ignore => default_ignored, :force_polling => nil } }
let(:opts) do
{ :ignore => default_ignored, :force_polling => nil, :wait_for_delay => nil }
end

before do
allow(Listen)
Expand Down