From 0fde781f2bf9414fc9ff2bc31c5034007835afde Mon Sep 17 00:00:00 2001 From: Mike Slinn Date: Wed, 11 Sep 2024 09:55:28 -0400 Subject: [PATCH] Fix `--livereload-ignore` option (#9570) Merge pull request 9570 --- docs/_data/config_options/serve.yml | 8 +++++++- lib/jekyll/commands/serve.rb | 6 ++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/_data/config_options/serve.yml b/docs/_data/config_options/serve.yml index 29f05eb0..2504045e 100644 --- a/docs/_data/config_options/serve.yml +++ b/docs/_data/config_options/serve.yml @@ -17,7 +17,13 @@ - name: Live reload ignore - description: File glob patterns for LiveReload to ignore. + description: >- + File glob patterns for LiveReload to ignore.

+ Ensure that patterns are quoted when passed via the command-line to deter your shell from + expanding them.

Note: The given glob patterns are matched against + the relative_path attribute of the processed resource. In the event Jekyll + reloads a relative_path matching the pattern in spite of being quoted, try listing + the pattern(s) under the config file option key. option: "livereload_ignore: [ GLOB1,... ]" flag: "--livereload-ignore GLOB1[,GLOB2,...]" diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index e019d99a..6abd893d 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -28,7 +28,7 @@ module Jekyll "the server is started.",], "livereload" => ["-l", "--livereload", "Use LiveReload to automatically refresh browsers",], - "livereload_ignore" => ["--livereload-ignore ignore GLOB1[,GLOB2[,...]]", + "livereload_ignore" => ["--livereload-ignore GLOB1[,GLOB2[,...]]", Array, "Files for LiveReload to ignore. " \ "Remember to quote the values so your shell " \ @@ -138,7 +138,6 @@ module Jekyll end end - # rubocop:disable Metrics/AbcSize def register_reload_hooks(opts) require_relative "serve/live_reload_reactor" @reload_reactor = LiveReloadReactor.new @@ -160,7 +159,7 @@ module Jekyll if @changed_pages && @reload_reactor && @reload_reactor.running? ignore, @changed_pages = @changed_pages.partition do |p| Array(opts["livereload_ignore"]).any? do |filter| - File.fnmatch(filter, Jekyll.sanitized_path(p.relative_path)) + File.fnmatch(filter, p.relative_path) end end Jekyll.logger.debug "LiveReload:", "Ignoring #{ignore.map(&:relative_path)}" @@ -169,7 +168,6 @@ module Jekyll @changed_pages = nil end end - # rubocop:enable Metrics/AbcSize # Do a base pre-setup of WEBRick so that everything is in place # when we get ready to party, checking for an setting up an error page