From 61e014a2d670a37e9d4a282ae7be0f1c43d676ad Mon Sep 17 00:00:00 2001 From: Daniel Perez Date: Sat, 14 May 2016 11:11:16 +0900 Subject: [PATCH] Fix local command bug. --- lib/commands/version_commands.sh | 4 ++++ test/version_commands.bats | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/commands/version_commands.sh b/lib/commands/version_commands.sh index a462fbab..02626b47 100644 --- a/lib/commands/version_commands.sh +++ b/lib/commands/version_commands.sh @@ -66,6 +66,10 @@ version_command() { local version=$3 + if [ $cmd = "local" ]; then + file=$(pwd)/.tool-versions + fi + check_if_version_exists $plugin $version if [ -f $file ] && grep $plugin $file > /dev/null; then diff --git a/test/version_commands.bats b/test/version_commands.bats index c93b8152..ccfcb811 100644 --- a/test/version_commands.bats +++ b/test/version_commands.bats @@ -67,6 +67,16 @@ teardown() { run local_command bar [ "$status" -eq 0 ] [ "$output" = "1.0.0" ] + + rm .tool-versions + run local_command foo 1.2.0 + [ -f .tool-versions ] + + run local_command foo + [ "$status" -eq 0 ] + [ "$output" = "1.2.0" ] + run global_command foo + [ "$output" = "1.0.0" ] } @test "local should fallback to legacy-file when enabled" {