Accept multiple config files from command line #945

Merged
merged 3 commits into from Apr 12, 2013

Projects

None yet

6 participants

@voidfiles
Contributor

Parse config as if it can contain multiple references to config files.
This allows you to pass in multiple config files from the command line

Helps with issues #514 and #703

@voidfiles voidfiles Accept multiple config files from command line
Parse config as if it can contain multiple references to config files.
This allows you to pass in multiple config files from the command line

Helps with issues #514 and #703
df1efef
@parkr parkr commented on an outdated diff Apr 10, 2013
lib/jekyll.rb
@@ -136,13 +136,19 @@ def self.configuration(override)
source = override['source'] || Jekyll::DEFAULTS['source']
# Get configuration from <source>/_config.yml or <source>/<config_file>
- config_file = override.delete('config')
- config_file = File.join(source, "_config.yml") if config_file.to_s.empty?
+ config_files = override.delete('config')
+ config_files = File.join(source, "_config.yml") if config_files.to_s.empty?
+ # If config is a list of space separate config files
+ config_files = config_files.split(' ')
@parkr
parkr Apr 10, 2013 Member

I'm worried that this is no good in case someone has a space in their file path

@parkr
parkr Apr 10, 2013 Member

Look into commander accepting an Array instead of String like it does right now in bin/jekyll

@voidfiles
Contributor

I ran the tests in ruby 1.8.7 and it passes for me I am not sure how I can replicate the travis env.

@maul-esel
Contributor

Passes for me as well. It's annoying that due to that SystemStackError you can't see what's actually wrong 😒

@parkr parkr commented on an outdated diff Apr 11, 2013
lib/jekyll.rb
@@ -136,13 +136,20 @@ def self.configuration(override)
source = override['source'] || Jekyll::DEFAULTS['source']
# Get configuration from <source>/_config.yml or <source>/<config_file>
- config_file = override.delete('config')
- config_file = File.join(source, "_config.yml") if config_file.to_s.empty?
+ config_files = override.delete('config')
+ config_files = File.join(source, "_config.yml") if config_files.to_s.empty?
+ if not config_files.is_a? Array
@parkr
parkr Apr 11, 2013 Member

please use !. @mojombo prefers to use the more C-like versions - no python allowed ;)

@parkr
parkr Apr 11, 2013 Member

better yet, use unless

@parkr parkr and 1 other commented on an outdated diff Apr 11, 2013
test/test_configuration.rb
@@ -46,10 +46,20 @@ class TestConfiguration < Test::Unit::TestCase
assert_equal Jekyll::DEFAULTS.deep_merge({ "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => @paths[:other] })
end
- should "load default config if path passed is empty" do
+ should "load multiple config files" do
@parkr
parkr Apr 11, 2013 Member

wait. whyyyyy did you take my test?

@voidfiles
voidfiles Apr 11, 2013 Contributor

I am not sure. I will change that.

@voidfiles
Contributor

funny, the tests passed this time.

@parkr
Member
parkr commented Apr 12, 2013

LGTM, will ask for another pair of eyes

@mattr-
Member
mattr- commented Apr 12, 2013

👍 :shipit:

@parkr parkr merged commit 17c1e23 into jekyll:master Apr 12, 2013

1 check passed

default The Travis build passed
Details
@parkr parkr added a commit that referenced this pull request Apr 12, 2013
@parkr parkr Update history to reflect merge of #945 64aa31b
@benbalter
Contributor

Are you able to replicate this behavior via command line? Can't get it to work. What am I doing wrong?

jekyll build --config _config.yml _config2.yml
Configuration file: _config.yml
...
@parkr
Member
parkr commented Apr 14, 2013

The option should probably be --config FILE1, FILE2, ... or something. It specifies Array though. Hm.

@benbalter
Contributor

Tried:

  • --config foo bar
  • --config foo, bar
  • --config [foo, bar] (also with quotes)
  • --config foo --config bar

No such luck.

@voidfiles
Contributor

--config FILE1,FILE2 no spaces, but I found some other problems as well. I have a patch I am about to push.

@voidfiles
Contributor

Here is a pull request that updates the command line description to make it a better example of how to do it. Also multi config files just weren't working.

#973

@parkr parkr added a commit that referenced this pull request Apr 14, 2013
@parkr parkr Merge branch 'master' of github.com:mojombo/jekyll
* 'master' of github.com:mojombo/jekyll:
  Print deprecation warnings for 'server', 'watch' and 'auto' when loaded from files. Fixes #972
  Fixes multiple config loading. Closes #973. Rel: #945.
d33f45f
@netpoetica netpoetica referenced this pull request in dannygarcia/grunt-jekyll Jun 20, 2013
Closed

No Async #21

@jekyllbot jekyllbot locked and limited conversation to collaborators Feb 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.