Skip to content

Commit

Permalink
Enhancement: Adjust doctor command
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed May 4, 2018
1 parent 1a4d272 commit 1233181
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/jekyll/commands/doctor.rb
Expand Up @@ -39,18 +39,28 @@ def healthy?(site)
!conflicting_urls(site),
!urls_only_differ_by_case(site),
proper_site_url?(site),
properly_gathered_drafts?(site),
properly_gathered_posts?(site),
].all?
end

def properly_gathered_drafts?(site)
outside_custom_collections_dir(site, "_drafts")
end

def properly_gathered_posts?(site)
outside_custom_collections_dir(site, "_posts")
end

private
def outside_custom_collections_dir?(site, directory)
return true if site.config["collections_dir"].empty?
posts_at_root = site.in_source_dir("_posts")
return true unless File.directory?(posts_at_root)
at_root = site.in_source_dir(directory)
return true unless File.directory?(at_root)
Jekyll.logger.warn "Warning:",
"Detected '_posts' directory outside custom `collections_dir`!"
"Detected '#{directory}' directory outside custom `collections_dir`!"
Jekyll.logger.warn "",
"Please move '#{posts_at_root}' into the custom directory at " \
"Please move '#{directory}' into the custom directory at " \
"'#{site.in_source_dir(site.config["collections_dir"])}'"
false
end
Expand Down

0 comments on commit 1233181

Please sign in to comment.