Fix current when .tool-versions contains comments

This commit is contained in:
Daniel Perez 2019-03-31 20:39:36 +01:00
parent f2674374b0
commit b8ee616318
2 changed files with 11 additions and 1 deletions

View File

@ -269,7 +269,7 @@ parse_asdf_version_file() {
if [ -f "$file_path" ]; then
local version
version=$(grep "^${plugin_name} " "$file_path" | sed -e "s/^${plugin_name} //")
version=$(strip_tool_version_comments "$file_path" | grep "^${plugin_name} "| sed -e "s/^${plugin_name} //")
if [ -n "$version" ]; then
echo "$version"
return 0

View File

@ -121,3 +121,13 @@ foobar 1.0.0 (set by $PROJECT_DIR/.tool-versions)"
[ "$status" -eq 0 ]
echo "$output" | grep "Oohes nooes ~! No plugins installed"
}
@test "current should handle comments" {
cd $PROJECT_DIR
echo "dummy 1.2.0 # this is a comment" >> $PROJECT_DIR/.tool-versions
run asdf current "dummy"
echo "$output"
[ "$status" -eq 0 ]
[ "$output" = "1.2.0 (set by $PROJECT_DIR/.tool-versions)" ]
}