chore: finalize remaining project artifacts
This commit is contained in:
@@ -1,14 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
APP_DIR="/home/cnc/桌面/cnc_wams/web-rtcp-5axis-sim-plan/app/dist"
|
||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
|
||||
APP_SOURCE_DIR="${SCRIPT_DIR}/app"
|
||||
APP_DIR="${APP_SOURCE_DIR}/dist"
|
||||
PORT="8092"
|
||||
URL="http://127.0.0.1:${PORT}/"
|
||||
LOG_DIR="${HOME}/.cache/web-rtcp-5axis-sim"
|
||||
LOG_FILE="${LOG_DIR}/local-server.log"
|
||||
BUILD_LOG_FILE="${LOG_DIR}/local-build.log"
|
||||
|
||||
mkdir -p "$LOG_DIR"
|
||||
|
||||
if [[ ! -f "${APP_DIR}/index.html" ]]; then
|
||||
npm --prefix "$APP_SOURCE_DIR" run build >"$BUILD_LOG_FILE" 2>&1 || {
|
||||
echo "failed to build web app; see ${BUILD_LOG_FILE}" >&2
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
is_serving() {
|
||||
curl -fsS --max-time 1 "$URL" >/dev/null 2>&1
|
||||
}
|
||||
@@ -23,6 +33,11 @@ if ! is_serving; then
|
||||
done
|
||||
fi
|
||||
|
||||
if ! is_serving; then
|
||||
echo "local web server failed to start at ${URL}; see ${LOG_FILE}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if command -v google-chrome-stable >/dev/null 2>&1; then
|
||||
exec google-chrome-stable --new-window "$URL"
|
||||
elif command -v google-chrome >/dev/null 2>&1; then
|
||||
|
||||
Reference in New Issue
Block a user