asdf/lib/commands/command-plugin-update.bash

26 lines
734 B
Bash
Raw Normal View History

# -*- sh -*-
2015-05-17 11:20:51 -07:00
plugin_update_command() {
if [ "$#" -lt 1 ]; then
display_error "usage: asdf plugin-update {<name> | --all} [git-ref]"
2016-07-03 04:15:57 -07:00
exit 1
fi
local plugin_name="$1"
local gitref="${2:-master}"
2015-05-20 21:31:09 -07:00
if [ "$plugin_name" = "--all" ]; then
for dir in "$(asdf_data_dir)"/plugins/*; do
2017-09-04 10:04:56 -07:00
echo "Updating $(basename "$dir")..."
(cd "$dir" && git fetch -p -u origin "$gitref:$gitref" && git checkout -f "$gitref")
2015-05-17 03:47:45 -07:00
done
2015-05-17 00:46:56 -07:00
else
2017-09-04 10:04:56 -07:00
local plugin_path
plugin_path="$(get_plugin_path "$plugin_name")"
2017-09-04 10:04:56 -07:00
check_if_plugin_exists "$plugin_name"
2015-05-20 21:31:09 -07:00
echo "Updating $plugin_name..."
(cd "$plugin_path" && git fetch -p -u origin "$gitref:$gitref" && git checkout -f "$gitref")
2015-05-17 00:46:56 -07:00
fi
}
plugin_update_command "$@"