Fix #5233: Increase our ability to detect Windows.

This increases our ability to detect Windows, and to detect Windows+Bash.  It also adds a message to Windows for users who try to "--watch", also noting to to them to check out the Windows ticket so eventually somebody pings us if this issue is fixed. /cc @TAGraves
This commit is contained in:
Jordon Bedwell 2016-08-11 19:21:50 -05:00
parent 54281530fb
commit f1f8319566
No known key found for this signature in database
GPG Key ID: E051B220DFADB075
2 changed files with 55 additions and 7 deletions

View File

@ -71,12 +71,23 @@ 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"
else
External.require_with_graceful_fail "jekyll-watch"
watch_method = Jekyll::Watcher.method(:watch)
if watch_method.parameters.size == 1
watch_method.call(options)
watch_method.call(
options
)
else
watch_method.call(options, site)
watch_method.call(
options, site
)
end
end
end
end # end of class << self

View File

@ -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