From 038c1f3d0f4791b1bb48a56691a39f0153df01d7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 28 Apr 2014 23:27:10 -0700 Subject: [PATCH] Find `.nvmrc` files upwards. --- nvm.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nvm.sh b/nvm.sh index 8b23a12..6f0b955 100644 --- a/nvm.sh +++ b/nvm.sh @@ -35,9 +35,13 @@ if [ -z "$NVM_NODEJS_ORG_MIRROR" ]; then fi nvm_find_nvmrc() { - if [ -e '.nvmrc' ]; then - echo '.nvmrc' - fi + typeset dir="$PWD" + typeset found="" + while [ "$dir" != "/" ] && [ "$found" = "" ]; do + found=$(find "$dir" -maxdepth 1 -name ".nvmrc") + dir=$(cd "$dir/.." && pwd -P) + done + echo $found } # Obtain nvm version from rc file