Treeprit.Code (Treeprit v0.1.0) View Source
This module will help compiling your scripts.
Invoke the load_scripts/1
inside your main script file. This function takes the folder path as the first argument and as result will load all scripts from that folder.
That way your .exs file is ready to run all modules declared in that folder.
Link to this section Summary
Functions
Load scripts inside a folder
It is the same for load_script/1
, but the first argument is the application name.
Link to this section Functions
Specs
load_scripts(String.t()) :: :ok | :throw
Load scripts inside a folder
Example
# inside your seed.exs file
Treeprit.Code.load_scripts("repo/seeds")
Treeprit.new()
|> Treeprit.run(:role, MyProject.Seeds.Role)
|> Treeprit.run(:user, MyProject.Seeds.User)
|> Treeprit.run_if_env(:user_admin, MyProject.Seeds.UserAdmin, :dev)
|> Treeprit.finally()
Specs
It is the same for load_script/1
, but the first argument is the application name.