From 04aa8c9658b280b2d2a721b151ae2088557493ce Mon Sep 17 00:00:00 2001 From: Shahryar Tavakkoli Date: Thu, 27 Jun 2024 16:53:32 +0330 Subject: [PATCH] VIP - change Mix.env to installer function --- lib/application.ex | 2 +- lib/event/event.ex | 2 +- lib/installer/installer.ex | 2 +- lib/mnesia_repo.ex | 5 ++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/application.ex b/lib/application.ex index 317fba9..522aacd 100644 --- a/lib/application.ex +++ b/lib/application.ex @@ -14,7 +14,7 @@ defmodule MishkaInstaller.Application do Supervisor.start_link(children, opts) end - if Mix.env() == :test do + if MishkaInstaller.__information__().env == :test do def supervised_children() do [] end diff --git a/lib/event/event.ex b/lib/event/event.ex index 9247a6f..9746a29 100644 --- a/lib/event/event.ex +++ b/lib/event/event.ex @@ -93,7 +93,7 @@ defmodule MishkaInstaller.Event.Event do ################################################################################ @doc false @spec database_config() :: keyword() - if Mix.env() != :test do + if MishkaInstaller.__information__().env != :test do def database_config(), do: Keyword.merge(@mnesia_info, attributes: keys(), disc_copies: [node()]) else diff --git a/lib/installer/installer.ex b/lib/installer/installer.ex index 2887fe6..69d1338 100644 --- a/lib/installer/installer.ex +++ b/lib/installer/installer.ex @@ -64,7 +64,7 @@ defmodule MishkaInstaller.Installer.Installer do ################################################################################ @doc false @spec database_config() :: keyword() - if Mix.env() != :test do + if MishkaInstaller.__information__().env != :test do def database_config(), do: Keyword.merge(@mnesia_info, attributes: keys(), disc_copies: [node()]) else diff --git a/lib/mnesia_repo.ex b/lib/mnesia_repo.ex index 0a7f7e0..b746316 100644 --- a/lib/mnesia_repo.ex +++ b/lib/mnesia_repo.ex @@ -6,7 +6,6 @@ defmodule MishkaInstaller.MnesiaRepo do alias MishkaInstaller.Installer.Installer alias MnesiaAssistant.Error, as: MError - @env_mod Mix.env() # I got the basic idea from https://github.com/processone/ejabberd @identifier :mishka_mnesia_repo #################################################################################### @@ -44,7 +43,7 @@ defmodule MishkaInstaller.MnesiaRepo do "Identifier: #{inspect(@identifier)} ::: Placing Mnesia address of the generator in the mentioned system variable." ) - mnesia_dir = ".mnesia" <> "/#{@env_mod}" + mnesia_dir = ".mnesia" <> "/#{MishkaInstaller.__information__().env}" config = Application.get_env(:mishka, Mishka.MnesiaRepo, mnesia_dir: mnesia_dir) File.mkdir_p(config[:mnesia_dir]) |> MError.error_description(@identifier) Application.put_env(:mnesia, :dir, config[:mnesia_dir] |> to_charlist) @@ -114,7 +113,7 @@ defmodule MishkaInstaller.MnesiaRepo do end @impl true - if Mix.env() != :test do + if MishkaInstaller.__information__().env != :test do def handle_info(:health_check, state) do # TODO: this function can have some checker Process.send_after(__MODULE__, :health_check, 1000)