mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Merge pull request #539 from asdf-vm/leonid-shevtsov-install-through-plugins
Leonid shevtsov - install through plugins
This commit is contained in:
commit
d633db78bc
@ -37,21 +37,35 @@ get_concurrency() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
install_local_tool_versions() {
|
install_local_tool_versions() {
|
||||||
local asdf_versions_path
|
local plugins_path
|
||||||
asdf_versions_path=$(find_tool_versions)
|
plugins_path=$(get_plugin_path)
|
||||||
if [ -f "${asdf_versions_path}" ]; then
|
|
||||||
while IFS= read -r tool_line; do
|
|
||||||
IFS=' ' read -r -a tool_info <<< "$tool_line"
|
|
||||||
local tool_name
|
|
||||||
tool_name=$(echo "${tool_info[0]}" | xargs)
|
|
||||||
local tool_version
|
|
||||||
tool_version=$(echo "${tool_info[1]}" | xargs)
|
|
||||||
|
|
||||||
if ! [[ -z "$tool_name" || -z "$tool_version" ]]; then
|
local search_path
|
||||||
install_tool_version "$tool_name" "$tool_version"
|
search_path=$(pwd)
|
||||||
|
|
||||||
|
local some_tools_installed
|
||||||
|
|
||||||
|
if ls "$plugins_path" &> /dev/null; then
|
||||||
|
for plugin_path in "$plugins_path"/* ; do
|
||||||
|
local plugin_name
|
||||||
|
plugin_name=$(basename "$plugin_path")
|
||||||
|
|
||||||
|
local plugin_version_and_path
|
||||||
|
plugin_version_and_path="$(find_version "$plugin_name" "$search_path")"
|
||||||
|
|
||||||
|
if [ -n "$plugin_version_and_path" ]; then
|
||||||
|
local plugin_version
|
||||||
|
some_tools_installed='yes'
|
||||||
|
plugin_version=$(cut -d '|' -f 1 <<< "$plugin_version_and_path")
|
||||||
|
install_tool_version "$plugin_name" "$plugin_version"
|
||||||
fi
|
fi
|
||||||
done <<<"$(strip_tool_version_comments "$asdf_versions_path")"
|
done
|
||||||
else
|
else
|
||||||
|
echo "Install plugins first to be able to install tools"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$some_tools_installed" ]; then
|
||||||
echo "Either specify a tool & version in the command"
|
echo "Either specify a tool & version in the command"
|
||||||
echo "OR add .tool-versions file in this directory"
|
echo "OR add .tool-versions file in this directory"
|
||||||
echo "or in a parent directory"
|
echo "or in a parent directory"
|
||||||
|
@ -20,7 +20,7 @@ teardown() {
|
|||||||
[ $(cat $ASDF_DIR/installs/dummy/1.1/version) = "1.1" ]
|
[ $(cat $ASDF_DIR/installs/dummy/1.1/version) = "1.1" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "install_command installs even if the user is terrible and does not use newlines" {
|
@test "install_command without arguments installs even if the user is terrible and does not use newlines" {
|
||||||
cd $PROJECT_DIR
|
cd $PROJECT_DIR
|
||||||
echo -n 'dummy 1.2' > ".tool-versions"
|
echo -n 'dummy 1.2' > ".tool-versions"
|
||||||
run asdf install
|
run asdf install
|
||||||
@ -36,7 +36,7 @@ teardown() {
|
|||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "install_command should work in directory containing whitespace" {
|
@test "install_command without arguments should work in directory containing whitespace" {
|
||||||
WHITESPACE_DIR="$PROJECT_DIR/whitespace\ dir"
|
WHITESPACE_DIR="$PROJECT_DIR/whitespace\ dir"
|
||||||
mkdir -p "$WHITESPACE_DIR"
|
mkdir -p "$WHITESPACE_DIR"
|
||||||
cd "$WHITESPACE_DIR"
|
cd "$WHITESPACE_DIR"
|
||||||
@ -78,7 +78,7 @@ teardown() {
|
|||||||
[ "$lines_count" -eq "1" ]
|
[ "$lines_count" -eq "1" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "install_command should not generate shim for subdir" {
|
@test "install_command without arguments should not generate shim for subdir" {
|
||||||
cd $PROJECT_DIR
|
cd $PROJECT_DIR
|
||||||
echo 'dummy 1.0' > $PROJECT_DIR/.tool-versions
|
echo 'dummy 1.0' > $PROJECT_DIR/.tool-versions
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ teardown() {
|
|||||||
[ ! -f "$ASDF_DIR/shims/subdir" ]
|
[ ! -f "$ASDF_DIR/shims/subdir" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "install_command generated shim should pass all arguments to executable" {
|
@test "install_command without arguments should generate shim that passes all arguments to executable" {
|
||||||
# asdf lib needed to run generated shims
|
# asdf lib needed to run generated shims
|
||||||
cp -rf $BATS_TEST_DIRNAME/../{bin,lib} $ASDF_DIR/
|
cp -rf $BATS_TEST_DIRNAME/../{bin,lib} $ASDF_DIR/
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ teardown() {
|
|||||||
[ ! -f $ASDF_DIR/installs/dummy/1.1/version ]
|
[ ! -f $ASDF_DIR/installs/dummy/1.1/version ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "install_command uses a parent directory .tool-versions file if present" {
|
@test "install_command without arguments uses a parent directory .tool-versions file if present" {
|
||||||
# asdf lib needed to run generated shims
|
# asdf lib needed to run generated shims
|
||||||
cp -rf $BATS_TEST_DIRNAME/../{bin,lib} $ASDF_DIR/
|
cp -rf $BATS_TEST_DIRNAME/../{bin,lib} $ASDF_DIR/
|
||||||
|
|
||||||
@ -154,11 +154,25 @@ EOM
|
|||||||
[ "$output" == "HEY 1.0 FROM dummy" ]
|
[ "$output" == "HEY 1.0 FROM dummy" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "install_command skips comments in .tool-versions file" {
|
@test "install command without arguments installs versions from legacy files" {
|
||||||
|
echo 'legacy_version_file = yes' > $HOME/.asdfrc
|
||||||
|
echo '1.2' >> $PROJECT_DIR/.dummy-version
|
||||||
cd $PROJECT_DIR
|
cd $PROJECT_DIR
|
||||||
echo -n '# dummy 1.2' > ".tool-versions"
|
|
||||||
run asdf install
|
run asdf install
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ "$output" == "" ]
|
[ "$output" == "" ]
|
||||||
[ ! -f $ASDF_DIR/installs/dummy/1.2/version ]
|
[ -f $ASDF_DIR/installs/dummy/1.2/version ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "install command without arguments installs versions from legacy files in parent directories" {
|
||||||
|
echo 'legacy_version_file = yes' > $HOME/.asdfrc
|
||||||
|
echo '1.2' >> $PROJECT_DIR/.dummy-version
|
||||||
|
|
||||||
|
mkdir -p $PROJECT_DIR/child
|
||||||
|
cd $PROJECT_DIR/child
|
||||||
|
|
||||||
|
run asdf install
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$output" == "" ]
|
||||||
|
[ -f $ASDF_DIR/installs/dummy/1.2/version ]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user