Skip to content

Commit

Permalink
Merge pull request #1665 from jglick/json2yaml-INFRA-1666
Browse files Browse the repository at this point in the history
[INFRA-1666] If we are naming a file *.yml, convert from JSON first
  • Loading branch information
daniel-beck committed Jul 20, 2018
2 parents 275a4f4 + e793077 commit 35968b4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/fetch-external-resources
Expand Up @@ -7,6 +7,7 @@
require 'faraday'
require 'faraday_middleware'
require 'fileutils'
require 'json'
require 'uri'
require 'yaml'
require 'zip'
Expand Down Expand Up @@ -84,7 +85,13 @@ class Fetcher
f.write(frontmatter.to_yaml)
f.write("---\n")
end
f.write(response.body)
puts "Writing #{destination}"
if destination.include? ".yml"
puts "Converting JSON to YAML"
f.write(YAML.dump(JSON.load(response.body)))
else
f.write(response.body)
end
end

#if downloading a zip file, extract it
Expand Down

0 comments on commit 35968b4

Please sign in to comment.