mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
fix: don't override existing ASDF_DIR (#1008)
This commit is contained in:
parent
69ff2d0c9a
commit
73efc9fa97
20
asdf.sh
20
asdf.sh
@ -3,16 +3,18 @@
|
||||
# For Bash, ${BASH_SOURCE[0]} will be used to obtain this script's path.
|
||||
# For Zsh and others, $0 (the path to the shell or script) will be used.
|
||||
_under="$_"
|
||||
if [ "${BASH_SOURCE[0]}" != "" ]; then
|
||||
current_script_path="${BASH_SOURCE[0]}"
|
||||
elif [[ "$_under" == *".sh" ]]; then
|
||||
current_script_path="$_under"
|
||||
else
|
||||
current_script_path="$0"
|
||||
fi
|
||||
if [ -z "$ASDF_DIR" ]; then
|
||||
if [ -n "${BASH_SOURCE[0]}" ]; then
|
||||
current_script_path="${BASH_SOURCE[0]}"
|
||||
elif [[ "$_under" == *".sh" ]]; then
|
||||
current_script_path="$_under"
|
||||
else
|
||||
current_script_path="$0"
|
||||
fi
|
||||
|
||||
ASDF_DIR="$(dirname "$current_script_path")"
|
||||
fi
|
||||
export ASDF_DIR
|
||||
ASDF_DIR="$(dirname "$current_script_path")"
|
||||
# shellcheck disable=SC2016
|
||||
[ -d "$ASDF_DIR" ] || echo '$ASDF_DIR is not a directory'
|
||||
|
||||
@ -31,3 +33,5 @@ PATH="${ASDF_USER_SHIMS}:$PATH"
|
||||
# shellcheck source=lib/asdf.sh
|
||||
# Load the asdf wrapper function
|
||||
. "${ASDF_DIR}/lib/asdf.sh"
|
||||
|
||||
unset _under current_script_path ASDF_BIN ASDF_USER_SHIMS
|
||||
|
@ -21,6 +21,9 @@ setup() {
|
||||
mkdir -p $CHILD_DIR
|
||||
|
||||
cd $PROJECT_DIR
|
||||
|
||||
# asdf lib needed to run asdf.sh
|
||||
cp -rf $BATS_TEST_DIRNAME/../{bin,lib} $ASDF_DIR/
|
||||
}
|
||||
|
||||
teardown() {
|
||||
|
Loading…
Reference in New Issue
Block a user