Recompile on heroicons update
This commit is contained in:
@ -8,17 +8,35 @@ defmodule Heroicons.Generator do
|
|||||||
|
|
||||||
require Phoenix.Component
|
require Phoenix.Component
|
||||||
|
|
||||||
for path <- icon_paths do
|
recompile_quoted =
|
||||||
relative_path = Path.relative_to(path, :code.priv_dir(:heroicons))
|
quote do
|
||||||
generate(relative_path)
|
@paths_hash :erlang.md5(unquote(icon_paths))
|
||||||
end
|
def __mix_recompile__?() do
|
||||||
|
icon_paths =
|
||||||
|
Path.absname(unquote(icon_dir), :code.priv_dir(:heroicons))
|
||||||
|
|> Path.join("*.svg")
|
||||||
|
|> Path.wildcard()
|
||||||
|
|
||||||
|
:erlang.md5(icon_paths) != @paths_hash
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
icons_quoted =
|
||||||
|
for path <- icon_paths do
|
||||||
|
generate(path)
|
||||||
|
end
|
||||||
|
|
||||||
|
[recompile_quoted | icons_quoted]
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc false
|
@doc false
|
||||||
def generate(path) do
|
def generate(absolute_path) do
|
||||||
|
path = Path.relative_to(absolute_path, :code.priv_dir(:heroicons))
|
||||||
name = Heroicons.Generator.name(path)
|
name = Heroicons.Generator.name(path)
|
||||||
|
|
||||||
quote do
|
quote do
|
||||||
|
@external_resource unquote(absolute_path)
|
||||||
|
|
||||||
@doc Heroicons.Generator.doc(unquote(name), unquote(path))
|
@doc Heroicons.Generator.doc(unquote(name), unquote(path))
|
||||||
def unquote(name)(assigns_or_opts \\ [])
|
def unquote(name)(assigns_or_opts \\ [])
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ defmodule Mix.Tasks.Heroicons.Update do
|
|||||||
case args do
|
case args do
|
||||||
[] ->
|
[] ->
|
||||||
Heroicons.update()
|
Heroicons.update()
|
||||||
Mix.Task.run("deps.compile", [:heroicons, "--force"])
|
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
Mix.raise("Invalid arguments, expected: mix heroicons.update")
|
Mix.raise("Invalid arguments, expected: mix heroicons.update")
|
||||||
|
Reference in New Issue
Block a user