From 7e1f2a0d938052d4fa5ce6546f07b3decbd740cf Mon Sep 17 00:00:00 2001 From: Yasunori Fujie Date: Tue, 14 Sep 2021 22:44:53 +0900 Subject: [PATCH] fix: wait until the plugin update are finished (#1037) --- lib/commands/command-plugin-update.bash | 6 ++++-- test/plugin_update_command.bats | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/commands/command-plugin-update.bash b/lib/commands/command-plugin-update.bash index 1e6f531f7..acabb9256 100644 --- a/lib/commands/command-plugin-update.bash +++ b/lib/commands/command-plugin-update.bash @@ -8,12 +8,14 @@ plugin_update_command() { local plugin_name="$1" local gitref="${2}" + local plugins= if [ "$plugin_name" = "--all" ]; then if [ -d "$(asdf_data_dir)"/plugins ]; then - find "$(asdf_data_dir)"/plugins -mindepth 1 -maxdepth 1 -type d | while IFS= read -r dir; do + plugins=$(find "$(asdf_data_dir)"/plugins -mindepth 1 -maxdepth 1 -type d) + while IFS= read -r dir; do update_plugin "$(basename "$dir")" "$dir" "$gitref" & - done + done <<<"$plugins" wait fi else diff --git a/test/plugin_update_command.bats b/test/plugin_update_command.bats index 494bda44f..3769c70f9 100644 --- a/test/plugin_update_command.bats +++ b/test/plugin_update_command.bats @@ -112,3 +112,10 @@ teardown() { [ "$status" -eq 0 ] [ -f $ASDF_DIR/shims/dummy ] } + +@test "asdf plugin-update done for all plugins" { + local command="asdf plugin-update --all" + # Count the number of update processes remaining after the update command is completed. + run bash -c "${command} >/dev/null && ps -o 'ppid,args' | awk '{if(\$1==1 && \$0 ~ /${command}/ ) print}' | wc -l" + [[ 0 -eq "$output" ]] +}