mirror of
https://github.com/github/choosealicense.com
synced 2025-01-30 15:28:32 +01:00
33 lines
1016 B
Ruby
Executable File
33 lines
1016 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
require 'jekyll'
|
|
require 'tmpdir'
|
|
|
|
tmp_dir = Dir.mktmpdir
|
|
git_cmd = "git clone --depth=1 'https://github.com/spdx/license-list-data.git' #{tmp_dir}"
|
|
system(git_cmd)
|
|
html_dir = File.join(tmp_dir, 'html')
|
|
|
|
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']}..."
|
|
html_file = File.join(html_dir, "#{license.data['spdx-id']}.html")
|
|
txt_file = File.join(html_dir, "#{license.data['spdx-id']}.txt")
|
|
pandoc_cmd = "pandoc --columns=78 -f html -t plain -o #{txt_file} #{html_file}"
|
|
system(pandoc_cmd)
|
|
data = File.read(txt_file)
|
|
|
|
raw_content = File.read(license.path)
|
|
matches = raw_content.match Jekyll::Document::YAML_FRONT_MATTER_REGEXP
|
|
|
|
output = matches[1]
|
|
output << "---\n\n"
|
|
output << data.gsub(/ +\n/, "\n")
|
|
|
|
File.write(license.path, output)
|
|
end
|