Skip to content

Commit 04f1c19

Browse files
committed
Revert "fix: remove no longer used load_dotenv"
This reverts commit e95040a.
1 parent e95040a commit 04f1c19

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

scripts/util.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,32 @@
1717
import cruft
1818
import typer
1919
from cookiecutter.utils import work_in
20+
from dotenv import load_dotenv
2021
from typer.models import OptionInfo
2122

2223

2324
REPO_FOLDER: Path = Path(__file__).resolve().parent.parent
2425

26+
27+
def _load_env() -> None:
28+
"""Load environment variables from .env and .env.local (if present).
29+
30+
.env.local takes precedence over .env for any overlapping variables.
31+
"""
32+
env_file: Path = REPO_FOLDER / ".env"
33+
env_local_file: Path = REPO_FOLDER / ".env.local"
34+
35+
if env_file.exists():
36+
load_dotenv(env_file)
37+
38+
if env_local_file.exists():
39+
load_dotenv(env_local_file, override=True)
40+
41+
42+
# Load environment variables at module import time
43+
_load_env()
44+
45+
2546
FolderOption: partial[OptionInfo] = partial(
2647
typer.Option, dir_okay=True, file_okay=False, resolve_path=True, path_type=Path
2748
)

0 commit comments

Comments
 (0)