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