1. 程式人生 > >linux 自動化發布腳本

linux 自動化發布腳本

編碼 repo linux == https ont pat error log

#
GIT_HOME=/developer/git-repository/ 
DEST_PATH=/product/frontend/ 
#cd dir   
 if [ ! -n "$1" ];
   then
   echo -e "please enter name!"
   exit
 fi
 if [ $1 = "mall-fe" ];
   then
    echo -e "========Enter mall-fe================"
    cd $GIT_HOME$1
   else
   echo -e "not found!"
   exit
fi
#clear git dist
  echo 
-e "========Clear Git Dist================" rm -rf ./dist #git echo -e "=======git checkout master================" git checkout master echo -e "=======git pull================" git pull echo -e "=======npm install================" npm install --registry=https://registry.npm.taobao.org #npm run mydist echo
-e "=======npm run mydist================" npm run mydist if [ -d "./dist" ]; then #backup dest echo -e "=======dest backup================" mv $GEST_PATH$1/dist $DEST_PATH$1/dist.bak #copy echo -e "=======copy================" cp -R $DIT_HOME$1/dist $DEST_PATH$1 #echo result echo
"======= Deploy Success================" else echo "======= Deploy Error================" fi

註意[]裏的參數要有空格

技術分享圖片

不加空格會報錯

 if [ -d "./dist" ];
在npm run dist 的過程中報錯,可能是js文件編碼不規範造成的,修改刪除一些沒必要的代碼後就可以了

linux 自動化發布腳本