This commit is contained in:
Filip Dimovski 2017-06-06 01:20:37 +00:00 committed by GitHub
commit 53114667ac

35
nvm.sh
View File

@ -2727,6 +2727,41 @@ nvm() {
return 127
fi
# Install version if not available
if ! nvm ls "$PROVIDED_VERSION" &>/dev/null; then
tries_global=3
installed_flag="/tmp/.nvm_success"
while [ $tries_global -gt 0 ]; do
( nvm install "$PROVIDED_VERSION" && touch $installed_flag ) &
proc_id="$!"
#wait $proc_id
#result=$?
# Check every 2 seconds if the installation finished,
# if it did, install the needed npm packages and exit
tries_install=10
while [ $tries_install -gt 0 ]; do
if [ -f $installed_flag ]; then
npm install -g grunt-cli bower
rm $installed_flag &>/dev/null
return
fi
sleep 2
tries_install=$(( $tries_install - 1 ))
done
# Kill process after 20 seconds
kill $proc_id &>/dev/null
tries_global=$(( $tries_global - 1 ))
done
echo "Cannot install and use $PROVIDED_VERSION - network/disk space issues might be the reason."
return 1
fi
if [ "_$VERSION" = '_system' ]; then
if nvm_has_system_node && nvm deactivate >/dev/null 2>&1; then
if [ $NVM_USE_SILENT -ne 1 ]; then