Merge pull request #5235 from jekyll/update-windows-detection-to-check-proc-version
Merge pull request 5235
This commit is contained in:
commit
dddafccb36
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue