Merge pull request #403 from burnettk/support-tool-versions-without-newline

support .tool-versions content even if it does not end in a newline
This commit is contained in:
Trevor Brown 2018-11-20 09:18:41 -05:00 committed by GitHub
commit 22b709f94e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -40,7 +40,7 @@ install_local_tool_versions() {
local asdf_versions_path
asdf_versions_path=$(find_tool_versions)
if [ -f "${asdf_versions_path}" ]; then
while read -r tool_line; do
while IFS= read -r tool_line || [ -n "$tool_line" ]; do
IFS=' ' read -r -a tool_info <<< "$tool_line"
local tool_name
tool_name=$(echo "${tool_info[0]}" | xargs)

View File

@ -23,6 +23,14 @@ teardown() {
[ $(cat $ASDF_DIR/installs/dummy/1.1/version) = "1.1" ]
}
@test "install_command installs even if the user is terrible and does not use newlines" {
cd $PROJECT_DIR
echo -n 'dummy 1.2' > ".tool-versions"
run install_command
[ "$status" -eq 0 ]
[ $(cat $ASDF_DIR/installs/dummy/1.2/version) = "1.2" ]
}
@test "install_command set ASDF_CONCURRENCY" {
run install_command dummy 1.0
[ "$status" -eq 0 ]