Skip to content

Commit

Permalink
Merge pull request #32 from glenpike/nvm-guard
Browse files Browse the repository at this point in the history
Guard against running when nvm is installed.
  • Loading branch information
glenpike committed Feb 25, 2018
2 parents bf53f56 + ceb5d2b commit 87277d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -15,7 +15,7 @@ Download the script, run it:
```
./npm-g-nosudo.sh
```
or
or
```
wget -O- https://raw.githubusercontent.com/glenpike/npm-g_nosudo/master/npm-g-nosudo.sh | sh
```
Expand All @@ -36,6 +36,8 @@ source ~/.bashrc
```
or just open an new terminal session.

The script may not play nicely with [Node Version Manager](https://github.com/creationix/nvm) so it will not run if if finds the script installed.

## License

MIT © [Glen Pike](http://glenpike.co.uk)
9 changes: 9 additions & 0 deletions npm-g-nosudo.sh
Expand Up @@ -49,6 +49,15 @@ fi
#save in a temporary file.
npm -g list --depth=0 --parseable --long | cut -d: -f2 | grep -v '^npm@\|^$' >$to_reinstall

if [ -f $NVM_DIR/nvm.sh ]; then
printf "Found a possible nvm install - this script may cause issues, so will exit\n"
printf "a list of your current node's npm packages is in $to_reinstall\n\n"
printf "If you save this file somewhere else, e.g. ~/npm-reinstall.txt, you can run\n\n"
printf "cat ~/npm-reinstall.txt | xargs npm -f install\n\n"
printf "when you add new node versions with nvm\n"
exit
fi

if [ 1 = ${VERBOSE} ]; then
printf "\nRemoving existing packages temporarily - you might need your sudo password\n\n"
fi
Expand Down

0 comments on commit 87277d2

Please sign in to comment.