- make dev serves all courses on port 1312 with marp live reload - make dev-b/dev-c for single course on 1313/1314 - dev-kill only kills specific ports instead of all marp processes - add generate-root-index.sh for prod build overview page - cleanup function uses exec + trap instead of pid files
45 lines
1.0 KiB
Bash
Executable File
45 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Development server for HdM slides
|
|
# Usage:
|
|
# ./dev-server.sh - Marp live server for all courses (port 1312)
|
|
# ./dev-server.sh 223015b 1313 - Marp live server for single course
|
|
# ./dev-server.sh 223015c 1314 - Marp live server for single course
|
|
|
|
set -e
|
|
|
|
# Configuration
|
|
SLIDES_DIR="slides"
|
|
COURSE="${1:-}"
|
|
DEV_PORT="${2:-1312}"
|
|
|
|
# Colors
|
|
GREEN='\033[0;32m'
|
|
BLUE='\033[0;34m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Kill existing process on our port only
|
|
kill_port() {
|
|
fuser -k "$DEV_PORT/tcp" 2>/dev/null || true
|
|
sleep 0.5
|
|
}
|
|
|
|
# Main
|
|
trap 'echo -e "\n${RED}Shutting down...${NC}"; kill 0; exit 0' SIGINT SIGTERM
|
|
|
|
kill_port
|
|
|
|
if [ -n "$COURSE" ]; then
|
|
SERVE_DIR="$SLIDES_DIR/$COURSE"
|
|
echo -e "${GREEN}Marp dev server${NC} · ${BLUE}$COURSE${NC}"
|
|
else
|
|
SERVE_DIR="$SLIDES_DIR"
|
|
echo -e "${GREEN}Marp dev server${NC} · ${BLUE}all courses${NC}"
|
|
fi
|
|
|
|
echo -e " ${BLUE}http://localhost:$DEV_PORT${NC}"
|
|
echo -e " ${BLUE}$SERVE_DIR/${NC}"
|
|
echo ""
|
|
|
|
PORT=$DEV_PORT exec npx @marp-team/marp-cli --server "$SERVE_DIR/"
|