mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-10 14:21:50 +00:00
locate .nvmrc without find
instead of using find and actually cd'ing into directories we're now using simple string replacement on the `pwd`
This commit is contained in:
parent
038c1f3d0f
commit
80e349edb1
22
nvm.sh
22
nvm.sh
@ -34,14 +34,22 @@ if [ -z "$NVM_NODEJS_ORG_MIRROR" ]; then
|
|||||||
export NVM_NODEJS_ORG_MIRROR="http://nodejs.org/dist"
|
export NVM_NODEJS_ORG_MIRROR="http://nodejs.org/dist"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
nvm_find_nvmrc() {
|
# Traverse up in directory tree to find containing folder
|
||||||
typeset dir="$PWD"
|
nvm_find_up() {
|
||||||
typeset found=""
|
local path
|
||||||
while [ "$dir" != "/" ] && [ "$found" = "" ]; do
|
path=$(pwd)
|
||||||
found=$(find "$dir" -maxdepth 1 -name ".nvmrc")
|
while [[ "$path" != "" && ! -e "$path/$1" ]]; do
|
||||||
dir=$(cd "$dir/.." && pwd -P)
|
path=${path%/*}
|
||||||
done
|
done
|
||||||
echo $found
|
echo "$path"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
nvm_find_nvmrc() {
|
||||||
|
local dir=$(nvm_find_up '.nvmrc')
|
||||||
|
if [ -e "$dir/.nvmrc" ]; then
|
||||||
|
echo "$dir/.nvmrc"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Obtain nvm version from rc file
|
# Obtain nvm version from rc file
|
||||||
|
Loading…
Reference in New Issue
Block a user