Update log output for an invalid theme directory (#7679)
Merge pull request 7679
This commit is contained in:
parent
6435bd6167
commit
ebe62e8a28
1
Gemfile
1
Gemfile
|
@ -31,6 +31,7 @@ group :test do
|
||||||
gem "rubocop-performance"
|
gem "rubocop-performance"
|
||||||
gem "test-dependency-theme", :path => File.expand_path("test/fixtures/test-dependency-theme", __dir__)
|
gem "test-dependency-theme", :path => File.expand_path("test/fixtures/test-dependency-theme", __dir__)
|
||||||
gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__)
|
gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__)
|
||||||
|
gem "test-theme-skinny", :path => File.expand_path("test/fixtures/test-theme-skinny", __dir__)
|
||||||
gem "test-theme-symlink", :path => File.expand_path("test/fixtures/test-theme-symlink", __dir__)
|
gem "test-theme-symlink", :path => File.expand_path("test/fixtures/test-theme-symlink", __dir__)
|
||||||
|
|
||||||
gem "jruby-openssl" if RUBY_ENGINE == "jruby"
|
gem "jruby-openssl" if RUBY_ENGINE == "jruby"
|
||||||
|
|
|
@ -57,6 +57,17 @@ Feature: Writing themes
|
||||||
And I should see "From your site." in "_site/assets/application.coffee"
|
And I should see "From your site." in "_site/assets/application.coffee"
|
||||||
And I should see "From your site." in "_site/assets/base.js"
|
And I should see "From your site." in "_site/assets/base.js"
|
||||||
|
|
||||||
|
Scenario: A theme with *just* layouts
|
||||||
|
Given I have a configuration file with "theme" set to "test-theme-skinny"
|
||||||
|
And I have an "index.html" page with layout "home" that contains "The quick brown fox."
|
||||||
|
When I run jekyll build
|
||||||
|
Then I should get a zero exit status
|
||||||
|
And the _site directory should exist
|
||||||
|
And I should see "Message: The quick brown fox." in "_site/index.html"
|
||||||
|
But I should not see "_includes" in the build output
|
||||||
|
And I should not see "_sass" in the build output
|
||||||
|
And I should not see "assets" in the build output
|
||||||
|
|
||||||
Scenario: Requiring dependencies of a theme
|
Scenario: Requiring dependencies of a theme
|
||||||
Given I have a configuration file with "theme" set to "test-dependency-theme"
|
Given I have a configuration file with "theme" set to "test-dependency-theme"
|
||||||
When I run jekyll build
|
When I run jekyll build
|
||||||
|
|
|
@ -62,11 +62,22 @@ module Jekyll
|
||||||
# escape the theme root.
|
# escape the theme root.
|
||||||
# However, symlinks are allowed to point to other directories within the theme.
|
# However, symlinks are allowed to point to other directories within the theme.
|
||||||
Jekyll.sanitized_path(root, File.realpath(Jekyll.sanitized_path(root, folder.to_s)))
|
Jekyll.sanitized_path(root, File.realpath(Jekyll.sanitized_path(root, folder.to_s)))
|
||||||
rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP
|
rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP => e
|
||||||
Jekyll.logger.warn "Invalid theme folder:", folder
|
log_realpath_exception(e, folder)
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def log_realpath_exception(err, folder)
|
||||||
|
return if err.is_a?(Errno::ENOENT)
|
||||||
|
|
||||||
|
case err
|
||||||
|
when Errno::EACCES
|
||||||
|
Jekyll.logger.error "Theme error:", "Directory '#{folder}' is not accessible."
|
||||||
|
when Errno::ELOOP
|
||||||
|
Jekyll.logger.error "Theme error:", "Directory '#{folder}' includes a symbolic link loop."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def gemspec
|
def gemspec
|
||||||
@gemspec ||= Gem::Specification.find_by_name(name)
|
@gemspec ||= Gem::Specification.find_by_name(name)
|
||||||
rescue Gem::LoadError
|
rescue Gem::LoadError
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Skinny</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Hello World</h1>
|
||||||
|
{{ content }}
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
layout: default
|
||||||
|
---
|
||||||
|
|
||||||
|
Message: {{ content }}
|
|
@ -0,0 +1,11 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
Gem::Specification.new do |s|
|
||||||
|
s.name = "test-theme-skinny"
|
||||||
|
s.version = "0.1.0"
|
||||||
|
s.licenses = ["MIT"]
|
||||||
|
s.summary = "This is a theme with just layouts used to test Jekyll"
|
||||||
|
s.authors = ["Jekyll"]
|
||||||
|
s.files = ["lib/example.rb"]
|
||||||
|
s.homepage = "https://github.com/jekyll/jekyll"
|
||||||
|
end
|
Loading…
Reference in New Issue