#!/bin/bash set -e # 如果构建失败,则退出,不能删除旧的包 if [ "$#" -ne 1 ] ; then echo "Usage: $0 BUILD_ENV" >&2 exit 1 fi pwd echo “build env: $1” pwd yarn npm run build:$1 mkdir -p ~/project/union-question/static-new/admin/temp cp -r dist ~/project/union-question/static-new/admin/temp cd ~/project/union-question/static-new/admin if [ -d "dist" ]; then currentTime=`date "+%Y%m%d%H%M%S"` echo "dist backup... $currentTime" tar cf admin-bak-$currentTime.tar.gz dist rm -rf dist/* fi mv temp/dist . rm -rf temp echo "ok..."