Skip to content
This repository was archived by the owner on Dec 30, 2025. It is now read-only.

Commit a2061f8

Browse files
committed
feat(ssl-manager.sh): add automatic .env.local file detection and variable export
Introduce a function to locate the .env.local file in the current or parent directories, allowing for automatic environment variable export. This change enhances the script's usability by eliminating the need for manual environment variable setup, ensuring that necessary configurations are loaded automatically. If the .env.local file is not found, a warning is issued, alerting the user to potential configuration issues.
1 parent 11959b6 commit a2061f8

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

scripts/ssl-manager.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,28 @@
66
# Single script to handle all SSL certificate operations
77
# ============================================================================
88

9+
# find .env.local in current or parent dirs
10+
find_env_file() {
11+
dir="$PWD"
12+
while true; do
13+
if [ -f "$dir/.env.local" ]; then
14+
echo "$dir/.env.local"
15+
return 0
16+
fi
17+
[ "$dir" = "/" ] && return 1
18+
dir="$(dirname "$dir")"
19+
done
20+
}
21+
22+
if envfile=$(find_env_file); then
23+
# automatically export all vars
24+
set -o allexport
25+
source "$envfile"
26+
set +o allexport
27+
else
28+
echo "warning: .env.local not found" >&2
29+
fi
30+
931
set -euo pipefail
1032

1133
# Configuration
@@ -312,4 +334,4 @@ main() {
312334
}
313335

314336
# Run main function
315-
main "$@"
337+
main "$@"

0 commit comments

Comments
 (0)