Leanote's Blog
I love Leanote!
Toggle navigation
Leanote's Blog
Home
Chrome
Git
Linux
Windows
Others
工具大全
VsCode
Expo
Html
JavaScript
Npm
Node
Mock
React-Native
React
TypeScript
小程序
插件
正则
Dva
Ant-Design-React
Umi
Vue
Vux
Ant-Design-Vue
Http
Java
flutter
开发小工具
About Me
Archives
Tags
shell 批量打包
2021-09-02 09:15:44
17
0
0
admin
### build.sh ``` #!/bin/bash ## ======= 批量打包 ======= ## RED_COLOR='\E[1;31m **********' GREEN_COLOR='\E[1;32m **********' YELLOW_COLOR='\E[1;33m **********' BLUE_COLOR='\E[1;34m **********' RES='********** \E[0m' y_dev="dev-20210420" y_master="master" h_dev="dev-20210804-haopinzhongguo" h_master="master-haopingzhongguo" fileName="admin" distPath="/c/Users/Administrator/Desktop/云仓前端包" [ $2 ] && distPath=$2 buildType=$1 successArr=() log() { case $1 in red) echo -e "\n${RED_COLOR}$2${RES}" ;; green) echo -e "\n${GREEN_COLOR}$2${RES}" ;; yellow) echo -e "\n${YELLOW_COLOR}$2${RES}" ;; blue) echo -e "\n${BLUE_COLOR}$2${RES}" ;; *) echo -e "\n**********$2**********" ;; esac } log blue 开始打包 if [[ ! -e $distPath ]]; then rm -rf $distPath mkdir $distPath cd $distPath mkdir 好品中国测试 好品中国正式 友云正式 cd - fi build() { git checkout $1 git pull origin $1 git push origin $1 git checkout $2 git pull origin $2 if [[ $buildType == merge ]]; then git merge $1 --no-edit fi git push origin $2 npm run build path="${distPath}/$3/$fileName.tar.gz" rm $path tar -zcvf $path dist/* valid build $@ $3 } valid() { str=${@: -1} isClash=$(git diff --check) if [[ ! -e dist || $? -ne 0 || ${#isClash} > 0 ]]; then curBranch=$(git symbolic-ref --short -q HEAD) log yellow "请确认分支【$curBranch】代码是否正确, 按回车键重新打包当前分支" if read -t 600 -s -p ""; then $@; else log red 打包失败 sleep 99999 exit 0 fi elif [[ $str ]]; then len=${#successArr[*]} successArr[$len]=$str fi } build $y_dev $y_master 友云正式 build $y_master $h_dev 好品中国测试 build $h_dev $h_master 好品中国正式 log green "【${successArr[*]}】打包成功, 文件已存入 $distPath" ``` ### package.json ``` script: { "build:all": "sh build.sh", // 打包 "build:all_merge": "sh build.sh merge", // 合并和打包 } ```
Pre:
html转换成AST
Next:
git pull, git merge的时候总是会有一条commit message
0
likes
17
Weibo
Wechat
Tencent Weibo
QQ Zone
RenRen
Submit
Sign in
to leave a comment.
No Leanote account?
Sign up now.
0
comments
More...
Table of content
No Leanote account? Sign up now.