mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
fix: warn if plugin does not support keeping downloads if configured (#1644)
This commit is contained in:
parent
240a5fbdea
commit
19515eda3b
@ -236,8 +236,13 @@ install_tool_version() {
|
|||||||
if [ $install_exit_code -eq 0 ] && [ $download_exit_code -eq 0 ]; then
|
if [ $install_exit_code -eq 0 ] && [ $download_exit_code -eq 0 ]; then
|
||||||
# Remove download directory if --keep-download flag or always_keep_download config setting are not set
|
# Remove download directory if --keep-download flag or always_keep_download config setting are not set
|
||||||
always_keep_download=$(get_asdf_config_value "always_keep_download")
|
always_keep_download=$(get_asdf_config_value "always_keep_download")
|
||||||
if [ ! "$keep_download" = "true" ] && [ ! "$always_keep_download" = "yes" ] && [ -d "$download_path" ]; then
|
if [ ! "$keep_download" = "true" ] && [ ! "$always_keep_download" = "yes" ]; then
|
||||||
|
if [ -d "$download_path" ]; then
|
||||||
rm -r "$download_path"
|
rm -r "$download_path"
|
||||||
|
else
|
||||||
|
printf '%s\n' "asdf: Warn: You have configured asdf to preserve downloaded files (with always_keep_download=yes or --keep-download). But" >&2
|
||||||
|
printf '%s\n' "asdf: Warn: the current plugin ($plugin_name) does not support that. Downloaded files will not be preserved." >&2
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
reshim_command "$plugin_name" "$full_version"
|
reshim_command "$plugin_name" "$full_version"
|
||||||
|
20
test/fixtures/dummy_plugin_no_download/LICENSE
vendored
Normal file
20
test/fixtures/dummy_plugin_no_download/LICENSE
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Akash Manohar J
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
3
test/fixtures/dummy_plugin_no_download/bin/install
vendored
Executable file
3
test/fixtures/dummy_plugin_no_download/bin/install
vendored
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
printf '%s' 'install'
|
@ -242,9 +242,9 @@ EOM
|
|||||||
echo 'legacy_version_file = yes' >"$HOME/.asdfrc"
|
echo 'legacy_version_file = yes' >"$HOME/.asdfrc"
|
||||||
echo '1.2.0' >>"$PROJECT_DIR/.dummy-version"
|
echo '1.2.0' >>"$PROJECT_DIR/.dummy-version"
|
||||||
cd "$PROJECT_DIR"
|
cd "$PROJECT_DIR"
|
||||||
|
|
||||||
run asdf install
|
run asdf install
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ -z "$output" ]
|
|
||||||
[ -f "$ASDF_DIR/installs/dummy/1.2.0/version" ]
|
[ -f "$ASDF_DIR/installs/dummy/1.2.0/version" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +257,6 @@ EOM
|
|||||||
|
|
||||||
run asdf install
|
run asdf install
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ -z "$output" ]
|
|
||||||
[ -f "$ASDF_DIR/installs/dummy/1.2.0/version" ]
|
[ -f "$ASDF_DIR/installs/dummy/1.2.0/version" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,3 +301,12 @@ EOM
|
|||||||
[ ! -d "$ASDF_DIR/installs/dummy-broken/1.1.0" ]
|
[ ! -d "$ASDF_DIR/installs/dummy-broken/1.1.0" ]
|
||||||
[ "$output" = "Download failed!" ]
|
[ "$output" = "Download failed!" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "install_command prints info message if plugin does not support preserving download data if configured" {
|
||||||
|
install_dummy_plugin_no_download
|
||||||
|
|
||||||
|
run asdf install dummy-no-download 1.0.0
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
[[ "$output" == *'asdf: Warn:'*'not be preserved'* ]]
|
||||||
|
}
|
||||||
|
@ -30,6 +30,12 @@ install_mock_plugin() {
|
|||||||
cp -r "$BATS_TEST_DIRNAME/fixtures/dummy_plugin" "$location/plugins/$plugin_name"
|
cp -r "$BATS_TEST_DIRNAME/fixtures/dummy_plugin" "$location/plugins/$plugin_name"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_mock_plugin_no_download() {
|
||||||
|
local plugin_name=$1
|
||||||
|
local location="${2:-$ASDF_DIR}"
|
||||||
|
cp -r "$BATS_TEST_DIRNAME/fixtures/dummy_plugin_no_download" "$location/plugins/$plugin_name"
|
||||||
|
}
|
||||||
|
|
||||||
install_mock_legacy_plugin() {
|
install_mock_legacy_plugin() {
|
||||||
local plugin_name=$1
|
local plugin_name=$1
|
||||||
local location="${2:-$ASDF_DIR}"
|
local location="${2:-$ASDF_DIR}"
|
||||||
@ -64,6 +70,10 @@ install_dummy_plugin() {
|
|||||||
install_mock_plugin "dummy"
|
install_mock_plugin "dummy"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_dummy_plugin_no_download() {
|
||||||
|
install_mock_plugin_no_download "dummy-no-download" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
install_dummy_legacy_plugin() {
|
install_dummy_legacy_plugin() {
|
||||||
install_mock_legacy_plugin "legacy-dummy"
|
install_mock_legacy_plugin "legacy-dummy"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user