Implement mix update script
This commit is contained in:
29
lib/mix/tasks/heroicons.ex
Normal file
29
lib/mix/tasks/heroicons.ex
Normal file
@ -0,0 +1,29 @@
|
||||
defmodule Mix.Tasks.Heroicons do
|
||||
@moduledoc """
|
||||
Invokes heroicons mix utilities.
|
||||
Usage:
|
||||
$ mix heroicons
|
||||
"""
|
||||
|
||||
@shortdoc "Invokes heroicons mix utilities"
|
||||
|
||||
use Mix.Task
|
||||
|
||||
@impl true
|
||||
def run(args) do
|
||||
{_opts, args} = OptionParser.parse!(args, strict: [])
|
||||
|
||||
case args do
|
||||
[] -> help()
|
||||
_ -> Mix.raise("Invalid arguments, expected: mix heroicons")
|
||||
end
|
||||
end
|
||||
|
||||
defp help() do
|
||||
Mix.Task.run("app.start")
|
||||
Mix.shell().info("Heroicons v#{Application.spec(:heroicons, :vsn)}")
|
||||
Mix.shell().info("Include Heroicons as SVG-strings in your Elixir/Phoenix project!")
|
||||
Mix.shell().info("\nAvailable tasks:\n")
|
||||
Mix.Tasks.Help.run(["--search", "heroicons."])
|
||||
end
|
||||
end
|
22
lib/mix/tasks/heroicons/update.ex
Normal file
22
lib/mix/tasks/heroicons/update.ex
Normal file
@ -0,0 +1,22 @@
|
||||
defmodule Mix.Tasks.Heroicons.Update do
|
||||
@moduledoc """
|
||||
Update heroicons.
|
||||
By default, it downloads the latest version but you
|
||||
can configure it in your config files, such as:
|
||||
config :heroicons, :version, "#{Heroicons.latest_version()}"
|
||||
"""
|
||||
|
||||
@shortdoc "Update heroicons assets"
|
||||
|
||||
use Mix.Task
|
||||
|
||||
@impl true
|
||||
def run(args) do
|
||||
{_opts, args} = OptionParser.parse!(args, strict: [])
|
||||
|
||||
case args do
|
||||
[] -> Heroicons.update()
|
||||
_ -> Mix.raise("Invalid arguments, expected: mix heroicons.update")
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user