diff --git a/README.md b/README.md index c4b3450..a8835d6 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ end ### 1. Generate `blend.exs` ``` -mix blend.init +mix blend.install ``` ### 2. Define your blends @@ -171,7 +171,7 @@ BLEND=plug_crypto_1 mix phx.server ## Tasks ``` -mix blend.init # Generate blend.exs +mix blend.install # Generate blend.exs mix blend.get # Generate blend lockfiles mix blend.update --all # Update blend lockfiles to latest possible versions mix blend.list # List blends diff --git a/lib/blend.ex b/lib/blend.ex index e80e82c..0b6de39 100644 --- a/lib/blend.ex +++ b/lib/blend.ex @@ -7,7 +7,7 @@ defmodule Blend do @premix_file_name "premix.exs" @premix_file_template File.read!(Path.join(__DIR__, "blend/templates/premix.exs")) - def init do + def install do case File.read(@blendfile_name) do {:ok, _} -> IO.puts("#{@blendfile_name} file already exists, doing nothing") diff --git a/lib/mix/tasks/blend/init.ex b/lib/mix/tasks/blend/init.ex index 89e4423..4fea554 100644 --- a/lib/mix/tasks/blend/init.ex +++ b/lib/mix/tasks/blend/init.ex @@ -1,22 +1,10 @@ defmodule Mix.Tasks.Blend.Init do - @shortdoc "Initializes an empty blend.exs file" - - @moduledoc """ - A task to generates an empty blend.exs file for you - to define your blends, if you don't yet have one. - - It is created with a commented example in it. - - ``` - $ mix blend.init - Successfully created blend.exs file - ``` - """ + @moduledoc false use Mix.Task @impl true def run(_args) do - Blend.init() + Blend.install() end end diff --git a/lib/mix/tasks/blend/install.ex b/lib/mix/tasks/blend/install.ex new file mode 100644 index 0000000..edb41ec --- /dev/null +++ b/lib/mix/tasks/blend/install.ex @@ -0,0 +1,22 @@ +defmodule Mix.Tasks.Blend.Install do + @shortdoc "Initializes an empty blend.exs file" + + @moduledoc """ + A task to generates an empty blend.exs file for you + to define your blends, if you don't yet have one. + + It is created with a commented example in it. + + ``` + $ mix blend.install + Successfully created blend.exs file + ``` + """ + + use Mix.Task + + @impl true + def run(_args) do + Blend.install() + end +end diff --git a/test/blend_test.exs b/test/blend_test.exs index 52943a1..81b5289 100644 --- a/test/blend_test.exs +++ b/test/blend_test.exs @@ -3,12 +3,12 @@ defmodule BlendTest do doctest Blend @tag :tmp_dir - test "init/0 generates blend file", %{tmp_dir: tmp_dir} do + test "install/0 generates blend file", %{tmp_dir: tmp_dir} do File.cd!( tmp_dir, fn -> refute File.exists?("blend.exs") - Mix.Task.run("blend.init") + Mix.Task.run("blend.install") assert File.exists?("blend.exs") end )