mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-12 15:11:50 +00:00
Introduce copy METHOD for installation
This method copies the folder containing install.sh (normally also containing the repo) to - unless of course the install.sh being executed is in (where nvm was installed) This is useful for vagrant to test local changes instead of pulling them from git and thus testing what's on the server and not local changes
This commit is contained in:
parent
e28a257f23
commit
736aacf4e1
23
install.sh
23
install.sh
@ -1,5 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get this script after dereferincing all symlinks
|
||||
# !! Doesn't check for circular symlinks !!
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
set -e
|
||||
|
||||
nvm_has() {
|
||||
@ -109,6 +119,19 @@ nvm_do_install() {
|
||||
exit 1
|
||||
fi
|
||||
install_nvm_as_script
|
||||
# Copies install.sh dir to installation dir
|
||||
elif [ "~$METHOD" = "~copy" ]; then
|
||||
local COPY=true
|
||||
if [ $DIR = $NVM_DIR ]; then
|
||||
echo "=> install.sh is already in $NVM_DIR"
|
||||
COPY=false
|
||||
elif [ -d $NVM_DIR ]; then
|
||||
echo "=> $NVM_DIR already exists and its contents will be replaced"
|
||||
fi
|
||||
mkdir -p $NVM_DIR
|
||||
if $COPY; then
|
||||
cp -R $DIR/* $NVM_DIR
|
||||
fi
|
||||
fi
|
||||
|
||||
echo
|
||||
|
Loading…
Reference in New Issue
Block a user