Upgrade --config to accept an array of files

This commit is contained in:
Alex Kessinger 2013-04-10 11:38:49 -07:00
parent df1efeff25
commit 1e209c9bf3
3 changed files with 7 additions and 6 deletions

View File

@ -44,7 +44,7 @@ command :build do |c|
c.syntax = 'jekyll build [options]' c.syntax = 'jekyll build [options]'
c.description = 'Build your site' c.description = 'Build your site'
c.option '--config [CONFIG_FILE]', 'Custom configuration file' c.option '--config [CONFIG_FILE]', Array, 'Custom configuration file'
c.option '--future', 'Publishes posts with a future date' c.option '--future', 'Publishes posts with a future date'
c.option '--limit_posts MAX_POSTS', 'Limits the number of posts to parse and publish' c.option '--limit_posts MAX_POSTS', 'Limits the number of posts to parse and publish'
c.option '-w', '--watch', 'Watch for changes and rebuild' c.option '-w', '--watch', 'Watch for changes and rebuild'
@ -63,7 +63,7 @@ command :serve do |c|
c.syntax = 'jekyll serve [options]' c.syntax = 'jekyll serve [options]'
c.description = 'Serve your site locally' c.description = 'Serve your site locally'
c.option '--config [CONFIG_FILE]', 'Custom configuration file' c.option '--config [CONFIG_FILE]', Array,'Custom configuration file'
c.option '--future', 'Publishes posts with a future date' c.option '--future', 'Publishes posts with a future date'
c.option '--limit_posts MAX_POSTS', 'Limits the number of posts to parse and publish' c.option '--limit_posts MAX_POSTS', 'Limits the number of posts to parse and publish'
c.option '-w', '--watch', 'Watch for changes and rebuild' c.option '-w', '--watch', 'Watch for changes and rebuild'

View File

@ -138,8 +138,9 @@ module Jekyll
# Get configuration from <source>/_config.yml or <source>/<config_file> # Get configuration from <source>/_config.yml or <source>/<config_file>
config_files = override.delete('config') config_files = override.delete('config')
config_files = File.join(source, "_config.yml") if config_files.to_s.empty? config_files = File.join(source, "_config.yml") if config_files.to_s.empty?
# If config is a list of space separate config files if not config_files.is_a? Array
config_files = config_files.split(' ') config_files = [config_files]
end
begin begin
config = {} config = {}

View File

@ -51,7 +51,7 @@ class TestConfiguration < Test::Unit::TestCase
mock(YAML).safe_load_file(@paths[:other]) { Hash.new } mock(YAML).safe_load_file(@paths[:other]) { Hash.new }
mock($stdout).puts("Configuration file: #{@paths[:default]}") mock($stdout).puts("Configuration file: #{@paths[:default]}")
mock($stdout).puts("Configuration file: #{@paths[:other]}") mock($stdout).puts("Configuration file: #{@paths[:other]}")
assert_equal Jekyll::DEFAULTS, Jekyll.configuration({ "config" => "#{@paths[:default]} #{@paths[:other]}" }) assert_equal Jekyll::DEFAULTS, Jekyll.configuration({ "config" => [@paths[:default], @paths[:other]] })
end end
should "load multiple config files and last config should win" do should "load multiple config files and last config should win" do
@ -59,7 +59,7 @@ class TestConfiguration < Test::Unit::TestCase
mock(YAML).safe_load_file(@paths[:other]) { {"baseurl" => "http://wahoo.dev"} } mock(YAML).safe_load_file(@paths[:other]) { {"baseurl" => "http://wahoo.dev"} }
mock($stdout).puts("Configuration file: #{@paths[:default]}") mock($stdout).puts("Configuration file: #{@paths[:default]}")
mock($stdout).puts("Configuration file: #{@paths[:other]}") mock($stdout).puts("Configuration file: #{@paths[:other]}")
assert_equal Jekyll::DEFAULTS.deep_merge({ "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => "#{@paths[:default]} #{@paths[:other]}" }) assert_equal Jekyll::DEFAULTS.deep_merge({ "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => [@paths[:default], @paths[:other]] })
end end
end end
end end