mirror of
https://github.com/github/choosealicense.com
synced 2024-12-22 12:50:24 +01:00
add script to vendor licenses from SPDX api
This commit is contained in:
parent
6c36a601a0
commit
2dc5291498
22
script/vendor-license-text
Executable file
22
script/vendor-license-text
Executable file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env ruby
|
||||
require 'jekyll'
|
||||
require 'open-uri'
|
||||
|
||||
site_path = File.expand_path("../", File.dirname(__FILE__))
|
||||
config = Jekyll.configuration("source" => site_path)
|
||||
site = Jekyll::Site.new(config)
|
||||
site.read
|
||||
site.collections['licenses'].docs.each do |license|
|
||||
puts "Updating the #{license.data["title"]}..."
|
||||
uri = "https://spdx.org/licenses/#{license.data["spdx-id"]}.json"
|
||||
data = JSON.parse open(uri).read
|
||||
|
||||
raw_content = File.read(license.path)
|
||||
matches = raw_content.match Jekyll::Document::YAML_FRONT_MATTER_REGEXP
|
||||
|
||||
output = matches[1]
|
||||
output << "---\n\n"
|
||||
output << data["standardLicenseTemplate"].gsub(/ +\n/, "\n")
|
||||
|
||||
File.write(license.path, output)
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user