Merge pull request #504 from asdf-vm/fix-current-comments

Fix current when .tool-versions contains comments
This commit is contained in:
Daniel Perez 2019-03-31 21:10:15 +01:00 committed by GitHub
commit 5e2468a16d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)" ]
}