Fix #3653: Add a doctor helper to test pwd's.

This commit is contained in:
Jordon Bedwell 2015-05-15 20:02:08 -05:00
parent e4e14e8860
commit ae11cae659
3 changed files with 49 additions and 3 deletions

View File

@ -30,6 +30,7 @@ module Jekyll
def healthy?(site)
[
fsnotify_buggy?(site),
!deprecated_relative_permalinks(site),
!conflicting_urls(site)
].all?
@ -59,8 +60,23 @@ module Jekyll
conflicting_urls
end
private
def fsnotify_buggy?(site)
return true if !Utils::Platforms.osx?
if Dir.pwd != `pwd`.strip
Jekyll.logger.error " " + <<-STR.strip.gsub(/\n\s+/, "\n ")
We have detected that there might be trouble using fsevent on your
operating system, you can read https://github.com/thibaudgg/rb-fsevent/wiki/no-fsevents-fired-(OSX-bug)
for possible work arounds or you can work around it immediately
with `--force-polling`.
STR
false
end
true
end
private
def collect_urls(urls, things, destination)
things.each do |thing|
dest = thing.destination(destination)

View File

@ -1,6 +1,6 @@
module Jekyll
module Utils
extend self
module Utils extend self
autoload :Platforms, 'jekyll/utils/platforms'
# Constants for use in #slugify
SLUGIFY_MODES = %w{raw default pretty}

View File

@ -0,0 +1,30 @@
module Jekyll
module Utils
module Platforms extend self
# Provides jruby? and mri? which respectively detect these two types of
# tested Engines we support, in the future we might probably support the
# other one that everyone used to talk about.
{ :jruby? => "jruby", :mri? => "ruby" }.each do |k, v|
define_method k do
::RUBY_ENGINE == v
end
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? => /mswin|mingw|cygwin/, :linux? => /linux/, \
:osx? => /darwin|mac os/, :unix? => /solaris|bsd/ }.each do |k, v|
define_method k do
!!(
RbConfig::CONFIG["host_os"] =~ v
)
end
end
end
end
end