Raise LoadError if the file doesn't exist but do not catch it. :)
This commit is contained in:
parent
a7efb86d5c
commit
253fc8c506
|
@ -126,7 +126,7 @@ module Jekyll
|
||||||
{}
|
{}
|
||||||
else
|
else
|
||||||
Jekyll.logger.error "Fatal:", "The configuration file '#{file}' could not be found."
|
Jekyll.logger.error "Fatal:", "The configuration file '#{file}' could not be found."
|
||||||
abort
|
raise LoadError
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ module Jekyll
|
||||||
new_config = read_config_file(config_file)
|
new_config = read_config_file(config_file)
|
||||||
configuration = configuration.deep_merge(new_config)
|
configuration = configuration.deep_merge(new_config)
|
||||||
end
|
end
|
||||||
rescue => err
|
rescue ArgumentError => err
|
||||||
Jekyll.logger.warn "WARNING:", "Error reading configuration. " +
|
Jekyll.logger.warn "WARNING:", "Error reading configuration. " +
|
||||||
"Using defaults (and options)."
|
"Using defaults (and options)."
|
||||||
$stderr.puts "#{err}"
|
$stderr.puts "#{err}"
|
||||||
|
|
|
@ -82,6 +82,7 @@ class TestConfiguration < Test::Unit::TestCase
|
||||||
context "loading configuration" do
|
context "loading configuration" do
|
||||||
setup do
|
setup do
|
||||||
@path = File.join(Dir.pwd, '_config.yml')
|
@path = File.join(Dir.pwd, '_config.yml')
|
||||||
|
@user_config = File.join(Dir.pwd, "my_config_file.yml")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "fire warning with no _config.yml" do
|
should "fire warning with no _config.yml" do
|
||||||
|
@ -102,6 +103,14 @@ class TestConfiguration < Test::Unit::TestCase
|
||||||
mock($stderr).puts("Configuration file: (INVALID) #{@path}".yellow)
|
mock($stderr).puts("Configuration file: (INVALID) #{@path}".yellow)
|
||||||
assert_equal Jekyll::Configuration::DEFAULTS, Jekyll.configuration({})
|
assert_equal Jekyll::Configuration::DEFAULTS, Jekyll.configuration({})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "fire warning when user-specified config file isn't there" do
|
||||||
|
mock(YAML).safe_load_file(@user_config) { raise SystemCallError, "No such file or directory - #{@user_config}" }
|
||||||
|
mock($stderr).puts(("Fatal: ".rjust(20) + "The configuration file '#{@user_config}' could not be found.").red)
|
||||||
|
assert_raises LoadError do
|
||||||
|
Jekyll.configuration({'config' => [@user_config]})
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
context "loading config from external file" do
|
context "loading config from external file" do
|
||||||
setup do
|
setup do
|
||||||
|
|
Loading…
Reference in New Issue