Skip to content

Commit

Permalink
Changed to auto start and stop app, can be turned off
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Balser committed Mar 11, 2019
1 parent f210eed commit 6381d63
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/divo/integration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ defmodule Divo.Integration do
"""

defmacro __using__(opts \\ []) do
auto_start = Keyword.get(opts, :auto_start, true)

quote do
import Mix.Tasks.Docker.{Start, Kill}

setup_all do
Mix.Tasks.Docker.Start.run(unquote(opts))

Mix.Project.config()
|> Keyword.get(:app)
|> Application.ensure_all_started()
app = Mix.Project.config() |> Keyword.get(:app)
if unquote(auto_start), do: Application.ensure_all_started(app)

on_exit(fn ->
if unquote(auto_start), do: Application.stop(app)
Mix.Tasks.Docker.Kill.run(unquote(opts))
end)

Expand Down

0 comments on commit 6381d63

Please sign in to comment.