Skip to content

Commit

Permalink
fix DotEnv for Julia 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed Apr 23, 2024
1 parent 1bbdd91 commit 76baab5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ArgParse = "1"
Base64 = "1.6"
Dates = "1.6"
Distributed = "1.6"
DotEnv = "1"
DotEnv = "0.3, 1"
EzXML = "1"
FilePathsBase = "0.9"
HTTP = "1"
Expand Down
5 changes: 5 additions & 0 deletions src/Loader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ Loads .env file if present
"""
function load_dotenv()
if isfile(Genie.config.env_file)
@static if VersionNumber(Genie.Assets.package_version(DotEnv)) >= v"1.0"
DotEnv.load!(Genie.config.env_file; override = true)
else
DotEnv.config(; path = Genie.config.env_file, override = true)
end
DotEnv.load!(Genie.config.env_file; override = true)
end

Expand Down
1 change: 1 addition & 0 deletions test/tests_loader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
@test get(ENV, "FOO", "") == ""
Genie.Loader.load_dotenv()
@test get(ENV, "FOO", "") == "bar"
delete!(ENV, "FOO")
end

0 comments on commit 76baab5

Please sign in to comment.