Don't crash the generator if api_names_out.yaml is absent (#746)

This commit is contained in:
Daniel Azuma 2018-12-05 14:54:11 -08:00 committed by GitHub
parent b1942bdc3e
commit 5f4abfdfec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -42,13 +42,13 @@ module Google
include NameHelpers include NameHelpers
def initialize(names_out_file_path = nil, names_file_path = nil) def initialize(names_out_file_path = nil, names_file_path = nil)
if names_out_file_path if names_out_file_path && File.file?(names_out_file_path)
logger.info { sprintf('Loading API names from %s', names_out_file_path) } logger.info { sprintf('Loading API names from %s', names_out_file_path) }
@names = YAML.load(File.read(names_out_file_path)) || {} @names = YAML.load(File.read(names_out_file_path)) || {}
else else
@names = {} @names = {}
end end
if names_file_path if names_file_path && File.file?(names_file_path)
logger.info { sprintf('Loading API names from %s', names_file_path) } logger.info { sprintf('Loading API names from %s', names_file_path) }
@names = @names.merge(YAML.load(File.read(names_file_path)) || {}) @names = @names.merge(YAML.load(File.read(names_file_path)) || {})
end end