From 7d5b14bca135ce521a48c00e54e2e34c7bb76773 Mon Sep 17 00:00:00 2001 From: sigoden Date: Thu, 6 Jun 2024 08:52:40 +0800 Subject: feat: support dotenv (#18) --- run/tool.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'run/tool.sh') diff --git a/run/tool.sh b/run/tool.sh index 4846c8e..faafddd 100755 --- a/run/tool.sh +++ b/run/tool.sh @@ -1,6 +1,12 @@ #!/usr/bin/env bash set -e +export LLM_FUNCTIONS_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd)" + +if [[ -f "$LLM_FUNCTIONS_DIR/.env" ]]; then + source "$LLM_FUNCTIONS_DIR/.env" +fi + if [[ "$0" == *tool.sh ]]; then FUNC_FILE="$1" FUNC_DATA="$2" @@ -12,8 +18,7 @@ if [[ "$FUNC_FILE" != *'.sh' ]]; then FUNC_FILE="$FUNC_FILE.sh" fi -PROJECT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd)" -FUNC_FILE="$PROJECT_DIR/tools/$FUNC_FILE" +FUNC_FILE="$LLM_FUNCTIONS_DIR/tools/$FUNC_FILE" if [[ "$OS" == "Windows_NT" ]]; then FUNC_FILE="$(cygpath -w "$FUNC_FILE")" -- cgit v1.2.3