Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"scripts": {
"format": "prettier --write .",
"preview": "./scripts/preview.sh",
"suggest:format": "echo \"\nTo resolve this, run: $(tput bold)npm run format$(tput sgr0)\" && exit 1",
"test:format": "prettier --check . || npm run suggest:format",
"test:spelling": "cspell \"spec/**/*.md\" README.md LICENSE.md",
Expand Down
26 changes: 26 additions & 0 deletions scripts/preview.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

GAP_DIR="GAP-${GAP:-0}"

DIM='\033[2m'
RESET='\033[0m'
YELLOW='\033[33m'
GREEN='\033[32m'
CLEAR='\033[2K\r'

log() {
local color="$1" icon="$2" msg="$3"
shift 3
printf "${CLEAR}${DIM}│${RESET} ${color}${icon}${RESET} ${msg}" "$@"
}

export -f log
export DIM RESET YELLOW GREEN CLEAR GAP_DIR

npx portless gaps --force npx nodemon -q \
--watch "$GAP_DIR" --ext md \
--exec "\
log \$YELLOW ◌ 'Building ${GAP_DIR}${DIM}...${RESET}' && \
npx spec-md ${GAP_DIR}/DRAFT.md > ${GAP_DIR}/Index.html && \
log \$GREEN ● 'Rebuilt ${GAP_DIR} ${DIM}%s${RESET}\n' \"\$(date +%H:%M:%S)\" && \
npx http-server ${GAP_DIR} -s"
Loading