Created
August 21, 2024 17:20
-
-
Save daveshah/b1496de36c215dbd1a60aa6bbf6f9d55 to your computer and use it in GitHub Desktop.
Quick elixir script to pull licenses from deps
This file contains hidden or 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
defmodule LicensePull do | |
def pull do | |
content = | |
create_map() | |
|> Enum.reduce("", fn %{name: name, license: license}, acc -> | |
acc <> | |
""" | |
---------------------------------------------------------------- | |
Name: #{name} | |
License: | |
#{license} | |
---------------------------------------------------------------- | |
""" | |
end) | |
File.write("licenses.txt", content, [:write]) | |
end | |
defp create_map do | |
Path.wildcard("deps/*/LICENSE") | |
|> Enum.map(fn path -> | |
%{ | |
name: String.replace(path, "deps/", "") |> String.replace("/LICENSE", ""), | |
license: File.read!(path) | |
} | |
end) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment