From 6a6d661c6f9a69686c38e99d6a87d90b00013fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Antunes?= Date: Sat, 9 Nov 2019 17:20:32 +0000 Subject: [PATCH] Fixes error swallowing when using .nvmrc (#42) When a .nvmrc exists in the folder with a version that it's not installed. fish-nvm swallows the error and says that command (node,npm,npx,etc) is not installed. --- functions/__nvm_run.fish | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/functions/__nvm_run.fish b/functions/__nvm_run.fish index 871bd61..569da97 100644 --- a/functions/__nvm_run.fish +++ b/functions/__nvm_run.fish @@ -9,11 +9,6 @@ function __nvm_run function run_command set stack (status stack-trace | grep called | cut -d " " -f 7) set count (count $argv) - if test "$count" -ge 2 - set args $argv[2..-1] - else - set args "" - end if type -fqP $argv[1]; and test "$stack[1]" != (which $argv[1]) set count (count $argv) @@ -48,12 +43,15 @@ function __nvm_run end if not test -n "$NVM_HAS_RUN" - if test -f .nvmrc; and nvm use > /dev/null 2>&1 - if can_run_command $argv[1] + if test -f .nvmrc; + set nvm_output (nvm use) + set nvm_status $status + if test $nvm_status -gt 0 + echo $nvm_output + end + if test $nvm_status -eq 0; and can_run_command $argv[1] set -gx NVM_HAS_RUN 1 run_command $argv - else - run_default $argv end else run_default $argv