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:
parent
54281530fb
commit
f1f8319566
|
@ -71,12 +71,23 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns nothing.
|
# Returns nothing.
|
||||||
def watch(site, options)
|
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"
|
External.require_with_graceful_fail "jekyll-watch"
|
||||||
watch_method = Jekyll::Watcher.method(:watch)
|
watch_method = Jekyll::Watcher.method(:watch)
|
||||||
if watch_method.parameters.size == 1
|
if watch_method.parameters.size == 1
|
||||||
watch_method.call(options)
|
watch_method.call(
|
||||||
|
options
|
||||||
|
)
|
||||||
else
|
else
|
||||||
watch_method.call(options, site)
|
watch_method.call(
|
||||||
|
options, site
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # end of class << self
|
end # end of class << self
|
||||||
|
|
|
@ -13,18 +13,55 @@ module Jekyll
|
||||||
end
|
end
|
||||||
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
|
# Provides windows?, linux?, osx?, unix? so that we can detect
|
||||||
# platforms. This is mostly useful for `jekyll doctor` and for testing
|
# platforms. This is mostly useful for `jekyll doctor` and for testing
|
||||||
# where we kick off certain tests based on the platform.
|
# 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
|
define_method k do
|
||||||
!!(
|
!!(
|
||||||
RbConfig::CONFIG["host_os"] =~ v
|
RbConfig::CONFIG["host_os"] =~ v
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
|
private
|
||||||
|
def proc_version
|
||||||
|
@cached_proc_version ||= begin
|
||||||
|
Pathutil.new(
|
||||||
|
"/proc/version"
|
||||||
|
).read
|
||||||
|
rescue Errno::ENOENT
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue