_npm.sh
-add support for global installed packages -no distract mode (for glabal packages)
This commit is contained in:
36
_npm.sh
36
_npm.sh
@@ -16,16 +16,44 @@
|
|||||||
|
|
||||||
# https://github.com/npm/npm/issues/17744
|
# https://github.com/npm/npm/issues/17744
|
||||||
|
|
||||||
|
# No distract mode
|
||||||
|
no_distract=false
|
||||||
|
|
||||||
|
local_path=/Users/bruno/Sites/node_modules/
|
||||||
|
|
||||||
echo -e "\033[1m🌿 npm \033[0m"
|
echo -e "\033[1m🌿 npm \033[0m"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
cd /Users/bruno/Sites/node_modules/
|
# Local packages
|
||||||
echo -e "\033[4mInstalled scripts:\033[0m"
|
#cd /Users/bruno/Sites/node_modules/
|
||||||
|
cd $local_path
|
||||||
|
echo -e "\033[4mLocal installed scripts:\033[0m"
|
||||||
npm ls
|
npm ls
|
||||||
outdated=$(npm outdated)
|
outdated=$(npm outdated)
|
||||||
|
if [ -n "$outdated" ]; then
|
||||||
|
echo "$outdated"
|
||||||
echo "$outdated" | awk '{print $1}' | xargs npm update
|
echo "$outdated" | awk '{print $1}' | xargs npm update
|
||||||
|
else
|
||||||
|
echo -e "\033[4mNo local packages updates.\033[0m"
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
# Global packages
|
||||||
|
echo -e "\033[4mGlobal installed scripts:\033[0m"
|
||||||
|
npm list -g --depth=0
|
||||||
|
g_outdated=$(npm outdated -g --depth=0)
|
||||||
|
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
|
||||||
|
else
|
||||||
|
echo "$g_outdated" | sed '1d' | awk '{print $1}' | xargs -n 1 npm install -g
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -e "\033[4mNo global packages updates.\033[0m"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $1 == "--npm_cleanup" ]]; then
|
if [[ $1 == "--npm_cleanup" ]]; then
|
||||||
echo "🌬 Cleaning npm cache"
|
echo "🌬 Cleaning npm cache"
|
||||||
npm cache clean
|
npm cache clean
|
||||||
@@ -33,3 +61,7 @@ if [[ $1 == "--npm_cleanup" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user