mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-10 22:31:51 +00:00
Merge 4c21abea52
into d2644b22f9
This commit is contained in:
commit
53114667ac
35
nvm.sh
35
nvm.sh
@ -2727,6 +2727,41 @@ nvm() {
|
|||||||
return 127
|
return 127
|
||||||
fi
|
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 [ "_$VERSION" = '_system' ]; then
|
||||||
if nvm_has_system_node && nvm deactivate >/dev/null 2>&1; then
|
if nvm_has_system_node && nvm deactivate >/dev/null 2>&1; then
|
||||||
if [ $NVM_USE_SILENT -ne 1 ]; then
|
if [ $NVM_USE_SILENT -ne 1 ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user