Skip to content

Commit

Permalink
handle testing while supporting piping in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
motdotla committed Jun 13, 2024
1 parent 9268614 commit 976106c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ VERSION="0.44.1"
DIRECTORY="/usr/local/bin"
RELEASES_URL="https://github.com/dotenvx/dotenvx/releases"

# for testing purposes
TEST_MODE=0

# usage
usage() {
echo "Usage: $0 [options] [command]"
echo ""
Expand Down Expand Up @@ -329,8 +333,9 @@ main() {
fi
}

# execute main only if the script is run directly, not sourced
if [[ "${BASH_SOURCE[0]}" == "$0" || "${BASH_EXECUTION_STRING}" == "$0" ]]; then
if test -n "$TEST_MODE"; then
echo "running in test mode"
else
main "$@"
exit $?
fi
1 change: 1 addition & 0 deletions spec/install_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Describe 'install.sh'
VERSION="0.44.1"
DIRECTORY="./spec/tmp"
CI=1
TEST_MODE=1
}

# remove the dotenvx binary before each test
Expand Down

0 comments on commit 976106c

Please sign in to comment.