From d71dff74ae89498c6df4755029b6965229f482a2 Mon Sep 17 00:00:00 2001 From: Jordon Bedwell Date: Fri, 7 Oct 2016 07:53:07 -0500 Subject: [PATCH 1/2] Fix #5462: Only shutdown watch in Bash On Windows. --- lib/jekyll/commands/build.rb | 8 ++++---- lib/jekyll/utils/platforms.rb | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/jekyll/commands/build.rb b/lib/jekyll/commands/build.rb index 3e43f955..d2916632 100644 --- a/lib/jekyll/commands/build.rb +++ b/lib/jekyll/commands/build.rb @@ -71,10 +71,10 @@ module Jekyll # # Returns nothing. def watch(site, options) - if Utils::Platforms.windows? - Jekyll.logger.warn "", "--watch arg is unsupported on Windows. " - Jekyll.logger.warn "", "If you are on Windows Bash, please see: " \ - "https://github.com/Microsoft/BashOnWindows/issues/216" + if Utils::Platforms.bash_on_windows? + Jekyll.logger.warn "", "--watch arg is unsupported in Bash on Windows. " + Jekyll.logger.warn "", "Please see: https://github.com/Microsoft/BashOnWindows/issues/216" + Jekyll.logger.warn "", "If iNotify is fixed, please file a ticket." else External.require_with_graceful_fail "jekyll-watch" diff --git a/lib/jekyll/utils/platforms.rb b/lib/jekyll/utils/platforms.rb index a16c239b..f66ef795 100644 --- a/lib/jekyll/utils/platforms.rb +++ b/lib/jekyll/utils/platforms.rb @@ -19,16 +19,29 @@ module Jekyll # /proc/version returns nothing to us. # -- - def really_windows? + def vanilla_windows? RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i && \ !proc_version end + # -- + # XXX: Remove in 4.0 + # -- + + alias_method :really_windows?, \ + :vanilla_windows? + + # + + def bash_on_windows? + RbConfig::CONFIG["host_os"] =~ %r!linux! && \ + proc_version =~ %r!microsoft!i + end + # def windows? - RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i || \ - proc_version =~ %r!microsoft!i + vanilla_windows? || bash_on_windows? end # From df45f2618790922e6f704d301628d0169346a1a3 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 10 Nov 2016 12:54:30 -0800 Subject: [PATCH 2/2] Builder.watch: only warn for Bash on Windows, still try watching. --- lib/jekyll/commands/build.rb | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/jekyll/commands/build.rb b/lib/jekyll/commands/build.rb index d2916632..3cea607c 100644 --- a/lib/jekyll/commands/build.rb +++ b/lib/jekyll/commands/build.rb @@ -71,23 +71,27 @@ module Jekyll # # Returns nothing. def watch(site, options) + # Warn Windows users that they might need to upgrade. if Utils::Platforms.bash_on_windows? - Jekyll.logger.warn "", "--watch arg is unsupported in Bash on Windows. " - Jekyll.logger.warn "", "Please see: https://github.com/Microsoft/BashOnWindows/issues/216" - Jekyll.logger.warn "", "If iNotify is fixed, please file a ticket." + Jekyll.logger.warn "", + "Auto-regeneration may not work on some Windows versions." + Jekyll.logger.warn "", + "Please see: https://github.com/Microsoft/BashOnWindows/issues/216" + Jekyll.logger.warn "", + "If it does not work, please upgrade Bash on Windows or "\ + "run Jekyll with --no-watch." + end + External.require_with_graceful_fail "jekyll-watch" + watch_method = Jekyll::Watcher.method(:watch) + if watch_method.parameters.size == 1 + watch_method.call( + options + ) else - External.require_with_graceful_fail "jekyll-watch" - watch_method = Jekyll::Watcher.method(:watch) - if watch_method.parameters.size == 1 - watch_method.call( - options - ) - else - watch_method.call( - options, site - ) - end + watch_method.call( + options, site + ) end end end # end of class << self