Consistency and clean

This commit is contained in:
Thomas Forgione 2019-07-02 16:38:29 +02:00
parent 1ff3b89028
commit 74348830db
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 12 additions and 7 deletions

View File

@ -259,8 +259,8 @@ update-wasm() {
return
fi
echo -e "\033[32;1m=== Updating wasmer ===\033[0m"
local start=`date +%s`
echo -e "\033[32;1m=== Updating wasmer ===\033[0m"
local old_path=$PWD
@ -272,16 +272,11 @@ update-wasm() {
git stash pop > /dev/null 2>&1
cd $old_path
local seconds=$((`date +%s` - $start))
local formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'`
echo -e "\033[32;1m=== Wasm updated in $formatted ===\033[0m"
command -v wapm > /dev/null 2>&1
if [ $? -ne 0 ]; then
return
fi
start=`date +%s`
echo -e "\033[32;1m=== Updating wapm packages ===\033[0m"
local output=$(wapm list -g | grep '^ _/' | cut -d '|' -f 1 | cut -d '/' -f 2 | while read package; do
@ -298,14 +293,24 @@ update-wasm() {
if [ "$output" != "" ]; then
echo -e "$output\n"
else
echo "No packages to update"
echo "No packages need updating."
fi
local update_packages=0
for package in $(echo "$output" | tail -n +2 | grep 'Yes' | cut -d ' ' -f 1); do
echo Updating $package
wapm install -g $package
update_packages=$(($update_packages + 1))
done
if [ $update_packages -gt 1 ]; then
echo "1 package updated."
elif [ $update_packages -gt 0 ]; then
echo "$update_packages packages updated."
else
echo "No packages need updating."
fi
local seconds=$((`date +%s` - $start))
local formatted=`date -ud "@$seconds" +'%H hours %M minutes %S seconds'`
echo -e "\033[32;1m=== Wapm packages updated in $formatted ===\033[0m"