Render theme-gem root only in development (#9680)
Merge pull request 9680
This commit is contained in:
parent
eba4dbcc72
commit
32074ef944
|
@ -183,7 +183,9 @@ jekyll:
|
|||
|
||||
theme:
|
||||
- name: theme.root
|
||||
description: Absolute path to the theme-gem.
|
||||
description: >-
|
||||
Absolute path to the theme-gem. Rendered only when environment variable <code>JEKYLL_ENV</code>
|
||||
is set to <code>development</code>.
|
||||
- name: theme.authors
|
||||
description: Comma separated string composed of the authors of the theme-gem.
|
||||
- name: theme.description
|
||||
|
|
|
@ -3,9 +3,12 @@
|
|||
module Jekyll
|
||||
module Drops
|
||||
class ThemeDrop < Drop
|
||||
delegate_methods :root
|
||||
delegate_method_as :runtime_dependencies, :dependencies
|
||||
|
||||
def root
|
||||
@root ||= ENV["JEKYLL_ENV"] == "development" ? @obj.root : ""
|
||||
end
|
||||
|
||||
def authors
|
||||
@authors ||= gemspec.authors.join(", ")
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ class TestThemeDrop < JekyllUnitTest
|
|||
"dependencies" => [],
|
||||
"description" => "This is a theme used to test Jekyll",
|
||||
"metadata" => {},
|
||||
"root" => theme_dir,
|
||||
"root" => "",
|
||||
"version" => "0.1.0",
|
||||
}
|
||||
expected.each_key do |key|
|
||||
|
@ -30,5 +30,22 @@ class TestThemeDrop < JekyllUnitTest
|
|||
assert_equal expected[key], @drop[key]
|
||||
end
|
||||
end
|
||||
|
||||
should "render gem root only in development mode" do
|
||||
with_env("JEKYLL_ENV", nil) do
|
||||
drop = fixture_site("theme" => "test-theme").to_liquid.theme
|
||||
assert_equal "", drop["root"]
|
||||
end
|
||||
|
||||
with_env("JEKYLL_ENV", "development") do
|
||||
drop = fixture_site("theme" => "test-theme").to_liquid.theme
|
||||
assert_equal theme_dir, drop["root"]
|
||||
end
|
||||
|
||||
with_env("JEKYLL_ENV", "production") do
|
||||
drop = fixture_site("theme" => "test-theme").to_liquid.theme
|
||||
assert_equal "", drop["root"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue