_npm.sh
-npm doctor -nvm list -current node -current npm
This commit is contained in:
42
_npm.sh
42
_npm.sh
@@ -19,15 +19,34 @@
|
||||
# No distract mode
|
||||
no_distract=false
|
||||
|
||||
doctor=false
|
||||
|
||||
local_path=/Users/bruno/Sites/node_modules/
|
||||
|
||||
echo -e "\033[1m🌿 npm \033[0m"
|
||||
echo ""
|
||||
|
||||
# version courante de node.js
|
||||
node_v=$(node -v)
|
||||
echo -e "\033[4m🌿 node.js\033[0m (current version): $node_v"
|
||||
|
||||
# version courante de npm
|
||||
npm_v=$(npm -v)
|
||||
echo -e "\033[4m🌿 npm\033[0m (current version): $npm_v"
|
||||
|
||||
# versions installées de node.js
|
||||
nvm_installed=$(brew info nvm | grep Cellar)
|
||||
if [ -n "$nvm_installed" ]; then
|
||||
source $(brew --prefix nvm)/nvm.sh
|
||||
node_install=$(nvm list)
|
||||
echo -e "\033[4m🌿 node.js\033[0m (installed versions): \n$node_install"
|
||||
fi
|
||||
echo
|
||||
|
||||
# Local packages
|
||||
#cd /Users/bruno/Sites/node_modules/
|
||||
cd $local_path
|
||||
echo -e "\033[4mLocal installed scripts:\033[0m"
|
||||
echo -e "\033[4m🌿 Local installed scripts:\033[0m"
|
||||
npm ls
|
||||
outdated=$(npm outdated)
|
||||
if [ -n "$outdated" ]; then
|
||||
@@ -40,22 +59,33 @@ fi
|
||||
echo ""
|
||||
|
||||
# Global packages
|
||||
echo -e "\033[4mGlobal installed scripts:\033[0m"
|
||||
echo -e "\033[4m🌿 Global installed scripts:\033[0m"
|
||||
npm list -g --depth=0
|
||||
g_outdated=$(npm outdated -g --depth=0)
|
||||
g_outdated=$(npm outdated -g)
|
||||
# update -> wanted ; install -> latest
|
||||
if [ -n "$g_outdated" ]; then
|
||||
if [ "$no_distract" = false ]; then
|
||||
echo "$g_outdated"
|
||||
echo "$g_outdated" | sed '1d' | awk '{print $1}' | xargs -p -n 1 npm install -g
|
||||
#echo "$g_outdated" | sed '1d' | awk '{print $1}' | xargs -p -n 1 npm install -g
|
||||
echo "$g_outdated" | sed '1d' | awk '{print $1}' | xargs -p -n 1 npm update -g
|
||||
else
|
||||
echo "$g_outdated" | sed '1d' | awk '{print $1}' | xargs -n 1 npm install -g
|
||||
#echo "$g_outdated" | sed '1d' | awk '{print $1}' | xargs -n 1 npm install -g
|
||||
echo "$g_outdated" | sed '1d' | awk '{print $1}' | xargs -n 1 npm update -g
|
||||
fi
|
||||
else
|
||||
echo -e "\033[4mNo global packages updates.\033[0m"
|
||||
fi
|
||||
|
||||
echo
|
||||
|
||||
# Maintenance
|
||||
if [ "$doctor" = true ]; then
|
||||
echo "🌿 The Doc is checking that everything is ok."
|
||||
npm doctor
|
||||
fi
|
||||
|
||||
if [[ $1 == "--npm_cleanup" ]]; then
|
||||
echo "🌬 Cleaning npm cache"
|
||||
echo "🌿 Cleaning npm cache"
|
||||
npm cache clean
|
||||
echo ""
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user