mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-07 20:31:01 -05:00
Extract common create_hook helper
This commit is contained in:
parent
2cc2ec160e
commit
5ccba5d7cc
2 changed files with 10 additions and 0 deletions
|
@ -70,6 +70,7 @@ load test_helper
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "RBENV_HOOK_PATH includes rbenv built-in plugins" {
|
@test "RBENV_HOOK_PATH includes rbenv built-in plugins" {
|
||||||
|
unset RBENV_HOOK_PATH
|
||||||
run rbenv echo "RBENV_HOOK_PATH"
|
run rbenv echo "RBENV_HOOK_PATH"
|
||||||
assert_success "${RBENV_ROOT}/rbenv.d:${BATS_TEST_DIRNAME%/*}/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d:/usr/lib/rbenv/hooks"
|
assert_success "${RBENV_ROOT}/rbenv.d:${BATS_TEST_DIRNAME%/*}/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d:/usr/lib/rbenv/hooks"
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ if [ -z "$RBENV_TEST_DIR" ]; then
|
||||||
|
|
||||||
export RBENV_ROOT="${RBENV_TEST_DIR}/root"
|
export RBENV_ROOT="${RBENV_TEST_DIR}/root"
|
||||||
export HOME="${RBENV_TEST_DIR}/home"
|
export HOME="${RBENV_TEST_DIR}/home"
|
||||||
|
export RBENV_HOOK_PATH="${RBENV_ROOT}/rbenv.d"
|
||||||
|
|
||||||
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
|
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
|
||||||
PATH="${RBENV_TEST_DIR}/bin:$PATH"
|
PATH="${RBENV_TEST_DIR}/bin:$PATH"
|
||||||
|
@ -129,3 +130,11 @@ path_without() {
|
||||||
path="${path#:}"
|
path="${path#:}"
|
||||||
echo "${path%:}"
|
echo "${path%:}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
create_hook() {
|
||||||
|
mkdir -p "${RBENV_HOOK_PATH}/$1"
|
||||||
|
touch "${RBENV_HOOK_PATH}/$1/$2"
|
||||||
|
if [ ! -t 0 ]; then
|
||||||
|
cat > "${RBENV_HOOK_PATH}/$1/$2"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue