diff --git a/lib/jekyll/commands/build.rb b/lib/jekyll/commands/build.rb index 38c584c7..3e43f955 100644 --- a/lib/jekyll/commands/build.rb +++ b/lib/jekyll/commands/build.rb @@ -71,12 +71,23 @@ module Jekyll # # Returns nothing. def watch(site, options) - External.require_with_graceful_fail "jekyll-watch" - watch_method = Jekyll::Watcher.method(:watch) - if watch_method.parameters.size == 1 - watch_method.call(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" + else - watch_method.call(options, site) + 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 end end end # end of class << self diff --git a/lib/jekyll/utils/platforms.rb b/lib/jekyll/utils/platforms.rb index b9455936..a16c239b 100644 --- a/lib/jekyll/utils/platforms.rb +++ b/lib/jekyll/utils/platforms.rb @@ -13,18 +13,55 @@ module Jekyll end end + # -- + # Allows you to detect "real" Windows, or what we would consider + # "real" Windows. That is, that we can pass the basic test and the + # /proc/version returns nothing to us. + # -- + + def really_windows? + RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i && \ + !proc_version + end + + # + + def windows? + RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i || \ + proc_version =~ %r!microsoft!i + end + + # + + def linux? + RbConfig::CONFIG["host_os"] =~ %r!linux! && \ + proc_version !~ %r!microsoft!i + end + # Provides windows?, linux?, osx?, unix? so that we can detect # platforms. This is mostly useful for `jekyll doctor` and for testing # where we kick off certain tests based on the platform. - { :windows? => %r!mswin|mingw|cygwin!, :linux? => %r!linux!, \ - :osx? => %r!darwin|mac os!, :unix? => %r!solaris|bsd! }.each do |k, v| + { :osx? => %r!darwin|mac os!, :unix? => %r!solaris|bsd! }.each do |k, v| define_method k do !!( RbConfig::CONFIG["host_os"] =~ v ) end end + + # + + private + def proc_version + @cached_proc_version ||= begin + Pathutil.new( + "/proc/version" + ).read + rescue Errno::ENOENT + nil + end + end end end end