Skip to content

Commit

Permalink
VIP - change some app env section name
Browse files Browse the repository at this point in the history
  • Loading branch information
shahryarjb committed Jun 30, 2024
1 parent 639521c commit f7f1a9e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
7 changes: 5 additions & 2 deletions lib/mishka_installer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,13 @@ defmodule MishkaInstaller do
- Set `MIX_ENV` as the **System env** or `:mishka, :project_env` as the **Application env**
"""
def __information__() do
env = System.get_env("MIX_ENV") || Application.get_env(:mishka, :project_env) || @project_env
env =
System.get_env("MIX_ENV") || Application.get_env(:mishka_installer, :project_env) ||
@project_env

%{
path: System.get_env("PROJECT_PATH") || Application.get_env(:mishka, :project_path),
path:
System.get_env("PROJECT_PATH") || Application.get_env(:mishka_installer, :project_path),
env: if(is_atom(env), do: env, else: String.to_atom(env))
}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mnesia_repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ defmodule MishkaInstaller.MnesiaRepo do
)

mnesia_dir = ".mnesia" <> "/#{MishkaInstaller.__information__().env}"
config = Application.get_env(:mishka, Mishka.MnesiaRepo, mnesia_dir: mnesia_dir)
config = Application.get_env(:mishka_installer, 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)

Expand Down
6 changes: 5 additions & 1 deletion test/event/event_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ defmodule MishkaInstallerTest.Event.EventTest do

Process.register(self(), :__mishka_installer_event_test__)

Application.put_env(:mishka, Mishka.MnesiaRepo, mnesia_dir: mnesia_dir, essential: [Event])
Application.put_env(:mishka_installer, Mishka.MnesiaRepo,
mnesia_dir: mnesia_dir,
essential: [Event]
)

MishkaInstaller.subscribe("mnesia")
MishkaInstaller.subscribe("event")
start_supervised!(MishkaInstaller.Event.EventHandler)
Expand Down
6 changes: 5 additions & 1 deletion test/event/hook_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ defmodule MishkaInstallerTest.Event.HookTest do

Process.register(self(), :__mishka_installer_event_test__)

Application.put_env(:mishka, Mishka.MnesiaRepo, mnesia_dir: mnesia_dir, essential: [Event])
Application.put_env(:mishka_installer, Mishka.MnesiaRepo,
mnesia_dir: mnesia_dir,
essential: [Event]
)

MishkaInstaller.subscribe("mnesia")
MishkaInstaller.subscribe("event")
start_supervised!(MishkaInstaller.Event.EventHandler)
Expand Down
2 changes: 1 addition & 1 deletion test/installer/installer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule MishkaInstallerTest.Installer.InstallerTest do

Process.register(self(), :__mishka_installer_test__)

Application.put_env(:mishka, Mishka.MnesiaRepo,
Application.put_env(:mishka_installer, Mishka.MnesiaRepo,
mnesia_dir: mnesia_dir,
essential: [Installer]
)
Expand Down

0 comments on commit f7f1a9e

Please sign in to comment.