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 9df2cff
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/jekyll/commands/doctor.rb
Expand Up @@ -39,19 +39,27 @@ def healthy?(site)
!conflicting_urls(site),
!urls_only_differ_by_case(site),
proper_site_url?(site),
properly_gathered_posts?(site),
properly_gathered_drafts_and_posts?(site),
].all?
end

def properly_gathered_posts?(site)
def properly_gathered_drafts_and_posts?(site)
return true if site.config["collections_dir"].empty?
posts_at_root = site.in_source_dir("_posts")
return true unless File.directory?(posts_at_root)

directories = ["_drafts", "_posts"]

directories.select do |directory|
File.directory?(site.in_source_dir(directory))
end

return true if directories.empty?

Jekyll.logger.warn "Warning:",
"Detected '_posts' directory outside custom `collections_dir`!"
"Detected '#{directories.join("', '")}' directory outside custom `collections_dir`!"
Jekyll.logger.warn "",
"Please move '#{posts_at_root}' into the custom directory at " \
"Please move '#{directories.join("', '")}' into the custom directory at " \
"'#{site.in_source_dir(site.config["collections_dir"])}'"

false
end

Expand Down

0 comments on commit 9df2cff

Please sign in to comment.