diff --git a/bin/postinstall b/bin/postinstall index bad88ba..0e0b458 100755 --- a/bin/postinstall +++ b/bin/postinstall @@ -3,8 +3,17 @@ # shellcheck source=../lib/utils.sh source "$(dirname "$0")/../lib/utils.sh" -if [ "$ASDF_SKIP_RESHIM" == "1" ]; then - echo "Run 'asdf reshim $(plugin_name) ${ASDF_INSTALL_VERSION:-$npm_config_node_version}' after installing the packages to reshim" -else - asdf reshim "$(plugin_name)" "${ASDF_INSTALL_VERSION:-$npm_config_node_version}" +# If the command contains this package it should be the last +# Or one of multiples packages being installed/removed +# There's no problem executing it more than once +if grep -qFw "\"$npm_package_name\"" <<< "$npm_config_argv"; then + plgn_name="$(plugin_name)" + current_version="${ASDF_INSTALL_VERSION:-$(asdf current "$plgn_name" | awk '{ print $2 }')}" + + if [ "$ASDF_SKIP_RESHIM" == "1" ]; then + echo "Run 'asdf reshim $plgn_name $current_version' after installing the packages to reshim" + else + echo "Reshiming npm packages..." + asdf reshim "$plgn_name" "$current_version" + fi fi diff --git a/npm-hooks/postuninstall b/npm-hooks/postuninstall new file mode 100755 index 0000000..1fb339d --- /dev/null +++ b/npm-hooks/postuninstall @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +asdf_nodejs_installs_path=$(dirname $(dirname $(dirname $NODE))) +asdf_nodejs_plugin_path=${asdf_nodejs_installs_path/installs/plugins} +bash ${asdf_nodejs_plugin_path}/bin/postinstall