+use npm outdated —long instead npm outdated
This commit is contained in:
2021-01-09 13:03:03 +01:00
parent e97ae7ec2c
commit 02648b8f83

View File

@@ -155,8 +155,12 @@ if [ -d "$local_path" ]; then
fi fi
echo -e "\n${underline}🌿 Search for local packages update...${reset}\n"
outdated=$(npm outdated) outdated=$(npm outdated)
if [ -n "$outdated" ]; then if [ -n "$outdated" ]; then
echo -e "\n${underline}🌿 Updating local packages...${reset}\n"
if [ "$no_distract" = false ]; then if [ "$no_distract" = false ]; then
#echo "$outdated" #echo "$outdated"
echo "$outdated" | awk '{print $1}' | xargs -p -n 1 npm update echo "$outdated" | awk '{print $1}' | xargs -p -n 1 npm update
@@ -166,7 +170,7 @@ if [ -d "$local_path" ]; then
fi fi
else else
echo -e "\n${underline}No local packages updates.${reset}" echo -e "${italic}No local packages updates.${reset}"
fi fi
fi fi
@@ -193,22 +197,39 @@ else
npm list -g --depth=0 npm list -g --depth=0
fi fi
# ========================================================================
# Tester npm outdated -g --long
g_outdated=$(npm outdated -g --parseable=true) #Packages update
echo -e "\n${underline}🌿 Search for global packages update...${reset}\n"
echo "$g_outdated" glong_outdated=$(npm outdated -g --long | sed '1d')
if [ -n "$glong_outdated" ]; then
echo -e "$glong_outdated\n"
echo -e "\n${underline}🌿 Updating global packages...${reset}\n"
while IFS= read -r line
do
pkg=$(echo "$line" | awk '{print $1}')
vers=$(echo "$line" | awk '{print $4}')
outdated="$pkg@$vers"
# TEST
version=$(echo "$line" | awk '{print $1 "@" $4}')
echo "$version"
# /test
# update -> wanted ; install -> latest
if [ -n "$g_outdated" ]; then
if [ "$no_distract" = false ]; then if [ "$no_distract" = false ]; then
echo "$g_outdated" | cut -d : -f 4 | xargs -p -n 1 npm -g install echo "$outdated" | xargs -p -n 1 npm -g install
echo ""
else else
echo "$g_outdated" | cut -d : -f 4 | xargs -n 1 npm -g install echo "$outdated" | xargs -n 1 npm -g install
echo ""
fi fi
done <<< "$glong_outdated"
else else
echo -e "${underline}No global packages updates.${reset}" echo -e "${italic}No global packages updates.${reset}"
fi fi
echo "" echo ""
@@ -218,11 +239,11 @@ echo ""
############### ###############
if [ "$doctor" = true ]; then if [ "$doctor" = true ]; then
echo "🌿 The Doc is checking that everything is ok." echo "${underline}🌿 The Doc is checking that everything is ok.${reset}\n"
npm doctor npm doctor
echo "" echo ""
echo "🔍 Verifying npm cache" echo "🔍 Verifying npm cache\n"
npm cache verify npm cache verify
echo "" echo ""
fi fi