Skip to content

Commit

Permalink
Merge branch 'blend-install'
Browse files Browse the repository at this point in the history
  • Loading branch information
grzuy committed Sep 24, 2024
2 parents 0a53231 + 1ccae23 commit fd4f1ba
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ end
### 1. Generate `blend.exs`

```
mix blend.init
mix blend.install
```

### 2. Define your blends
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/blend.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
16 changes: 2 additions & 14 deletions lib/mix/tasks/blend/init.ex
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions lib/mix/tasks/blend/install.ex
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions test/blend_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit fd4f1ba

Please sign in to comment.