mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Resolve symlink paths before altering .tool-version files.
This commit is contained in:
parent
f7b71ba86a
commit
34ad911539
@ -17,6 +17,11 @@ version_command() {
|
||||
file="$(pwd)/.tool-versions"
|
||||
fi
|
||||
|
||||
if [ -L "$file" ]; then
|
||||
# Resolve file path if symlink
|
||||
file="$(resolve_symlink "$file")"
|
||||
fi
|
||||
|
||||
check_if_plugin_exists "$plugin"
|
||||
|
||||
local version
|
||||
@ -24,6 +29,7 @@ version_command() {
|
||||
check_if_version_exists "$plugin" "$version"
|
||||
done
|
||||
|
||||
|
||||
if [ -f "$file" ] && grep "^$plugin " "$file" > /dev/null; then
|
||||
sed -i.bak -e "s/^$plugin .*$/$plugin ${versions[*]}/" "$file"
|
||||
rm "$file".bak
|
||||
|
@ -354,3 +354,12 @@ find_tool_versions() {
|
||||
search_path=$(dirname "$search_path")
|
||||
done
|
||||
}
|
||||
|
||||
resolve_symlink() {
|
||||
local symlink
|
||||
symlink="$1"
|
||||
|
||||
# This seems to be the only cross-platform way to resolve symlink paths to
|
||||
# the real file path
|
||||
ls -l "$symlink" | sed -e "s|.*-> \(.*\)|\1|"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user