Created
February 24, 2017 22:45
-
-
Save cornelius/6e2804f98c6672b89b136e8c84764bbd to your computer and use it in GitHub Desktop.
Script to fix missing topics in inqlude-data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require "json" | |
Dir.glob("*").each do |dir| | |
generic_manifest = "#{dir}/#{dir}.manifest" | |
if File.exist?(generic_manifest) | |
topics = JSON.parse(File.read(generic_manifest))["topics"] | |
if topics | |
puts "#{dir}: #{topics}" | |
end | |
end | |
Dir.glob("#{dir}/#{dir}.*.manifest").each do |manifest_file| | |
puts " #{manifest_file}" | |
manifest = JSON.parse(File.read(manifest_file)) | |
if !manifest["topics"] | |
manifest["topics"] = topics | |
File.open(manifest_file, "w") do |file| | |
file.write(JSON.pretty_generate(manifest)) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment