mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 09:38:16 -07:00
commit
85bebfaf0f
@ -58,7 +58,8 @@ write_shim_script() {
|
||||
cp "$plugin_shims_path/$executable_name" "$shim_path"
|
||||
elif [ -f "$shim_path" ]; then
|
||||
if ! grep "# asdf-plugin-version: $version" "$shim_path" > /dev/null; then
|
||||
sed -i'' -e "s/\(asdf-plugin: $plugin_name\)/\1\\"$'\n'"# asdf-plugin-version: $version/" "$shim_path"
|
||||
sed -i.bak -e "s/\(asdf-plugin: $plugin_name\)/\1\\"$'\n'"# asdf-plugin-version: $version/" "$shim_path"
|
||||
rm "$shim_path".bak
|
||||
fi
|
||||
else
|
||||
cat <<EOF > "$shim_path"
|
||||
@ -210,7 +211,8 @@ remove_shim_for_version() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
sed -i'' -e "/# asdf-plugin-version: $version/d" "$shim_path"
|
||||
sed -i.bak -e "/# asdf-plugin-version: $version/d" "$shim_path"
|
||||
rm "$shim_path".bak
|
||||
|
||||
if [ ! -f "$plugin_shims_path/$executable_name" ] && \
|
||||
! grep "# asdf-plugin-version" "$shim_path" > /dev/null || \
|
||||
|
@ -25,7 +25,8 @@ version_command() {
|
||||
done
|
||||
|
||||
if [ -f "$file" ] && grep "$plugin" "$file" > /dev/null; then
|
||||
sed -i -e "s/$plugin .*/$plugin ${versions[*]}/" "$file"
|
||||
sed -i.bak -e "s/$plugin .*/$plugin ${versions[*]}/" "$file"
|
||||
rm "$file".bak
|
||||
else
|
||||
echo "$plugin ${versions[*]}" >> "$file"
|
||||
fi
|
||||
|
@ -46,3 +46,24 @@ teardown() {
|
||||
run grep "asdf-plugin-version: 1.1" "$ASDF_DIR/shims/dummy"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "reshim should not duplicate shims" {
|
||||
cd $PROJECT_DIR
|
||||
|
||||
run install_command dummy 1.0
|
||||
run install_command dummy 1.1
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f "$ASDF_DIR/shims/dummy" ]
|
||||
|
||||
run rm $ASDF_DIR/shims/*
|
||||
[ "$status" -eq 0 ]
|
||||
[ "0" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
|
||||
|
||||
run reshim_command dummy
|
||||
[ "$status" -eq 0 ]
|
||||
[ "1" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
|
||||
|
||||
run reshim_command dummy
|
||||
[ "$status" -eq 0 ]
|
||||
[ "1" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
|
||||
}
|
||||
|
@ -63,6 +63,14 @@ teardown() {
|
||||
[ "$tool_version_contents" = "dummy 1.1.0" ]
|
||||
}
|
||||
|
||||
@test "local should not create a duplicate .tool-versions file if such file exists" {
|
||||
echo 'dummy 1.0.0' >> $PROJECT_DIR/.tool-versions
|
||||
|
||||
run local_command "dummy" "1.1.0"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(ls $PROJECT_DIR/.tool-versions* | wc -l)" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "local should overwrite the existing version if it's set" {
|
||||
echo 'dummy 1.0.0' >> $PROJECT_DIR/.tool-versions
|
||||
run local_command "dummy" "1.1.0"
|
||||
|
Loading…
Reference in New Issue
Block a user