mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Use a git repository for installing plugins.
This commit is contained in:
parent
68d759b5d8
commit
20cdbfe701
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,5 @@
|
||||
installs
|
||||
plugins
|
||||
shims
|
||||
repository
|
||||
.vagrant
|
||||
|
||||
|
2
help.txt
2
help.txt
@ -1,5 +1,5 @@
|
||||
MANAGE PLUGINS
|
||||
asdf plugin-add <name> <git-url> Add git repo as plugin
|
||||
asdf plugin-add <name> [<git-url>] Add a plugin
|
||||
asdf plugin-list List installed plugins
|
||||
asdf plugin-remove <name> Remove plugin and package versions
|
||||
asdf plugin-update <name> Update plugin
|
||||
|
@ -1,11 +1,23 @@
|
||||
plugin_add_command() {
|
||||
if [ "$#" -ne 2 ]; then
|
||||
display_error "usage: asdf plugin-add <name> <git-url>"
|
||||
if [[ $# -lt 1 || $# -gt 2 ]]; then
|
||||
display_error "usage: asdf plugin-add <name> [<git-url>]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local plugin_name=$1
|
||||
local source_url=$2
|
||||
|
||||
if [ -n "$2" ]; then
|
||||
local source_url=$2
|
||||
else
|
||||
initialize_or_update_repository
|
||||
local source_url=$(get_plugin_source_url $plugin_name)
|
||||
fi
|
||||
|
||||
if [ -z "$source_url" ]; then
|
||||
display_error "plugin $plugin_name not found in repository"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local plugin_path=$(get_plugin_path $plugin_name)
|
||||
|
||||
mkdir -p $(asdf_dir)/plugins
|
||||
|
26
lib/utils.sh
26
lib/utils.sh
@ -206,3 +206,29 @@ get_asdf_config_value() {
|
||||
get_asdf_config_value_from_file $default_config_path $key
|
||||
fi
|
||||
}
|
||||
|
||||
asdf_repository_url() {
|
||||
echo "https://github.com/doughsay/asdf-plugins.git"
|
||||
}
|
||||
|
||||
initialize_or_update_repository() {
|
||||
local repository_url=$(asdf_repository_url)
|
||||
local repository_path=$(asdf_dir)/repository
|
||||
|
||||
if [ -d $repository_path ]; then
|
||||
echo "updating plugin repository..."
|
||||
(cd $repository_path && git pull)
|
||||
else
|
||||
echo "initializing plugin repository..."
|
||||
git clone $repository_url $repository_path
|
||||
fi
|
||||
}
|
||||
|
||||
get_plugin_source_url() {
|
||||
local plugin_name=$1
|
||||
local plugin_config="$(asdf_dir)/repository/plugins/$plugin_name"
|
||||
|
||||
if [ -f $plugin_config ]; then
|
||||
cat $plugin_config | grep "repository" | awk -F'=' '{print $2}' | sed 's/ //'
|
||||
fi
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user