Skip to content

Commit 92b32f5

Browse files
Yamashita Yuumislav
authored andcommitted
Add before/after hooks for rbenv uninstall
1 parent 57d8918 commit 92b32f5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

bin/rbenv-uninstall

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ case "$DEFINITION" in
3838
;;
3939
esac
4040

41+
declare -a before_hooks after_hooks
42+
43+
before_uninstall() {
44+
local hook="$1"
45+
before_hooks["${#before_hooks[@]}"]="$hook"
46+
}
47+
48+
after_uninstall() {
49+
local hook="$1"
50+
after_hooks["${#after_hooks[@]}"]="$hook"
51+
}
52+
53+
for script in $(rbenv-hooks uninstall); do
54+
source "$script"
55+
done
56+
57+
4158
VERSION_NAME="${DEFINITION##*/}"
4259
PREFIX="${RBENV_ROOT}/versions/${VERSION_NAME}"
4360

@@ -54,7 +71,11 @@ if [ -z "$FORCE" ]; then
5471
esac
5572
fi
5673

74+
for hook in "${before_hooks[@]}"; do eval "$hook"; done
75+
5776
if [ -d "$PREFIX" ]; then
5877
rm -rf "$PREFIX"
5978
rbenv rehash
6079
fi
80+
81+
for hook in "${after_hooks[@]}"; do eval "$hook"; done

0 commit comments

Comments
 (0)