Skip to content

Instantly share code, notes, and snippets.

@daveshah
Created August 21, 2024 17:20
Show Gist options
  • Save daveshah/b1496de36c215dbd1a60aa6bbf6f9d55 to your computer and use it in GitHub Desktop.
Save daveshah/b1496de36c215dbd1a60aa6bbf6f9d55 to your computer and use it in GitHub Desktop.
Quick elixir script to pull licenses from deps
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