Skip to content

Commit

Permalink
Bump and patch DotEnv dependency (0.3 -> 1)
Browse files Browse the repository at this point in the history
  • Loading branch information
essenciary committed Feb 26, 2024
1 parent 175a220 commit 9dd9a6e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Genie"
uuid = "c43c736e-a2d1-11e8-161f-af95117fbd1e"
authors = ["Adrian Salceanu <e@essenciary.com>"]
version = "5.25.1"
authors = ["Adrian Salceanu <adrian@genieframework.com> and the amazing Genie contributors ♥️"]
version = "5.26.0"

[deps]
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
Expand Down Expand Up @@ -42,7 +42,7 @@ ArgParse = "1"
Base64 = "1.6"
Dates = "1.6"
Distributed = "1.6"
DotEnv = "0.3"
DotEnv = "1"
EzXML = "1"
FilePathsBase = "0.9"
HTTP = "1"
Expand Down
16 changes: 13 additions & 3 deletions src/Loader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ function bootstrap(context::Union{Module,Nothing} = default_context(context); sh
ENV_FILE_NAME = "env.jl"
GLOBAL_ENV_FILE_NAME = "global.jl"

if isfile(Genie.config.env_file)
DotEnv.config(; path = Genie.config.env_file, override = true)
end
load_dotenv()

if haskey(ENV, "GENIE_ENV")
Genie.config.app_env = ENV["GENIE_ENV"]
Expand All @@ -86,6 +84,18 @@ function bootstrap(context::Union{Module,Nothing} = default_context(context); sh
end


"""
Loads .env file if present
"""
function load_dotenv()
if isfile(Genie.config.env_file)
DotEnv.load!(Genie.config.env_file; override = true)
end

nothing
end


function print_banner()
printstyled("""
Expand Down
1 change: 1 addition & 0 deletions test/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FOO=bar
4 changes: 4 additions & 0 deletions test/tests_loader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@

order = Genie.Loader.sort_load_order("loader", readdir("loader"))
@test order == ["xyz.jl", "-my-test-file.jl", "def.jl", "Abc.jl", ".autoload", "Aaa.jl", "Abb.jl"]

@test get(ENV, "FOO", "") == ""
Genie.Loader.load_dotenv()
@test get(ENV, "FOO", "") == "bar"
end

0 comments on commit 9dd9a6e

Please sign in to comment.