9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/project_types/extension/features/argo_config.rb', line 9
def parse_yaml(context, permitted_keys = [])
file_name = File.join(context.root, CONFIG_FILE_NAME)
return {} unless File.size?(file_name)
begin
config = YAML.load_file(file_name)
return {} if config.nil?
unless config.is_a?(Hash)
raise ShopifyCLI::Abort, ShopifyCLI::Context.message("core.yaml.error.not_hash", CONFIG_FILE_NAME)
end
config.transform_keys!(&:to_sym)
assert_valid_config(config, permitted_keys) unless permitted_keys.empty?
config
rescue Psych::SyntaxError => e
raise(
ShopifyCLI::Abort,
ShopifyCLI::Context.message("core.yaml.error.invalid", CONFIG_FILE_NAME, e.message)
)
end
end
|