mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Add pre-install and pre-reshim hooks
This commit is contained in:
parent
9a79ac9526
commit
dcc3727cab
@ -9,7 +9,10 @@ Features
|
||||
The following hooks will be executed when set:
|
||||
|
||||
```shell
|
||||
pre_asdf_install_foo = echo will install foo version ${1}
|
||||
post_asdf_install_foo = echo installed foo version ${1}
|
||||
|
||||
pre_asdf_reshim_foo = echo will reshim foo version ${1}
|
||||
post_asdf_reshim_foo = echo reshimmed foo version ${1}
|
||||
|
||||
pre_foo_bar = echo about to execute command bar from foo with args: ${@}
|
||||
|
@ -96,6 +96,7 @@ install_tool_version() {
|
||||
export ASDF_INSTALL_PATH=$install_path
|
||||
export ASDF_CONCURRENCY=$concurrency
|
||||
mkdir "$install_path"
|
||||
asdf_run_hook "pre_asdf_install_${plugin_name}" "$full_version"
|
||||
bash "${plugin_path}"/bin/install
|
||||
)
|
||||
|
||||
|
@ -20,6 +20,7 @@ reshim_command() {
|
||||
|
||||
if [ "$full_version" != "" ]; then
|
||||
# generate for the whole package version
|
||||
asdf_run_hook "pre_asdf_reshim_$plugin_name" "$full_version_name"
|
||||
generate_shims_for_version "$plugin_name" "$full_version"
|
||||
asdf_run_hook "post_asdf_reshim_$plugin_name" "$full_version"
|
||||
else
|
||||
@ -30,6 +31,7 @@ reshim_command() {
|
||||
for install in "${plugin_installs_path}"/*/; do
|
||||
local full_version_name
|
||||
full_version_name=$(basename "$install" | sed 's/ref\-/ref\:/')
|
||||
asdf_run_hook "pre_asdf_reshim_$plugin_name" "$full_version_name"
|
||||
generate_shims_for_version "$plugin_name" "$full_version_name"
|
||||
remove_obsolete_shims "$plugin_name" "$full_version_name"
|
||||
asdf_run_hook "post_asdf_reshim_$plugin_name" "$full_version_name"
|
||||
|
@ -139,9 +139,18 @@ teardown() {
|
||||
[ ! -f $ASDF_DIR/installs/dummy/system/version ]
|
||||
}
|
||||
|
||||
@test "install command executes configured pre plugin install hook" {
|
||||
cat > $HOME/.asdfrc <<-'EOM'
|
||||
pre_asdf_install_dummy = echo will install dummy $1
|
||||
EOM
|
||||
|
||||
run install_command dummy 1.0
|
||||
[ "$output" == "will install dummy 1.0" ]
|
||||
}
|
||||
|
||||
@test "install command executes configured post plugin install hook" {
|
||||
cat > $HOME/.asdfrc <<-'EOM'
|
||||
post_asdf_install_dummy = eval echo HEY $version FROM $plugin_name
|
||||
post_asdf_install_dummy = echo HEY $version FROM $plugin_name
|
||||
EOM
|
||||
|
||||
run install_command dummy 1.0
|
||||
|
@ -99,6 +99,17 @@ teardown() {
|
||||
[ "1" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
|
||||
}
|
||||
|
||||
@test "reshim command executes configured pre hook" {
|
||||
run install_command dummy 1.0
|
||||
|
||||
cat > $HOME/.asdfrc <<-'EOM'
|
||||
pre_asdf_reshim_dummy = echo RESHIM
|
||||
EOM
|
||||
|
||||
run reshim_command dummy 1.0
|
||||
[ "$output" == "RESHIM" ]
|
||||
}
|
||||
|
||||
@test "reshim command executes configured post hook" {
|
||||
run install_command dummy 1.0
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user