lib/anyway/loaders/yaml.rb in anyway_config-2.1.0 vs lib/anyway/loaders/yaml.rb in anyway_config-2.2.0
- old
+ new
@@ -23,13 +23,17 @@
private
def parse_yml(path)
return {} unless File.file?(path)
require "yaml" unless defined?(::YAML)
+
+ # By default, YAML load will return `false` when the yaml document is
+ # empty. When this occurs, we return an empty hash instead, to match
+ # the interface when no config file is present.
if defined?(ERB)
- ::YAML.load(ERB.new(File.read(path)).result) # rubocop:disable Security/YAMLLoad
+ ::YAML.load(ERB.new(File.read(path)).result) || {} # rubocop:disable Security/YAMLLoad
else
- ::YAML.load_file(path)
+ ::YAML.load_file(path) || {}
end
end
alias_method :load_base_yml, :parse_yml
alias_method :load_local_yml, :parse_yml