-
Notifications
You must be signed in to change notification settings - Fork 8
/
compile.sh
executable file
·44 lines (38 loc) · 994 Bytes
/
compile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
shopt -q nullglob
NULLGLOB_WAS_SET=$?
shopt -s nullglob
FILES=$(echo *.bs)
if [ 1 -eq $NULLGLOB_WAS_SET ]; then
shopt -u nullglob
fi
set -e # Exit with nonzero exit code if anything fails
for SPEC in $FILES; do
echo Running bikeshed on $SPEC
if which bikeshed; then
bikeshed -f spec $SPEC
else
SPEC_OUT=${SPEC%.bs}.html
HTTP_STATUS=$(curl https://api.csswg.org/bikeshed/ \
--output ${SPEC_OUT} \
--write-out "%{http_code}" \
--header "Accept: text/plain, text/html" \
-F file=@${SPEC})
if [ "$HTTP_STATUS" -ne "200" ]; then
echo ""; cat $SPEC_OUT; echo ""
rm -f $SPEC_OUT
exit 1
fi
fi
done
OUTDIR=${1:-out}
mkdir -p $OUTDIR
if [ -d $OUTDIR ]; then
for SPEC in $FILES; do
SPEC_OUT=${SPEC%.bs}.html
if [ -f $SPEC_OUT ]; then
echo Move $SPEC_OUT into $OUTDIR/$SPEC_OUT
mv $SPEC_OUT $OUTDIR/$SPEC_OUT
fi
done
fi