onyx/src/build.sh

42 lines
914 B
Bash
Raw Normal View History

2022-08-13 20:33:44 +00:00
#!/bin/sh
# default program name
progname="onyx-scry"
# or use first cmd line arg
if [ ! -z "$1" ]; then
progname=$1
fi
if [ -e ${progname}.ts ]; then
rm ${progname}.ts
fi
2022-08-13 20:33:44 +00:00
# build the source map and concatenate the source
srcmap=$(mktemp)
2022-08-13 20:33:44 +00:00
for f in *.ts; do
lines=$(wc -l ${f})
set ${lines}
lines=$1
echo "${f}\t${lines}" >> ${srcmap}
2022-08-13 20:33:44 +00:00
cat ${f} >> ${progname}.ts
done
# generate temporary file for intermediate output
errorOut=$(mktemp)
# compile and write output to temporary file
tsc --strict --target ES2015 --outFile ../static/${progname}.js ${progname}.ts | sed -e s/\(/:/ -e s/,/:/ -e s/\):// | nobs >> ${errorOut}
2022-08-13 20:33:44 +00:00
# if sourcemapper panics you can uncomment this
# cat ${errorOut}
2022-08-13 20:33:44 +00:00
# translate lines into original source with the source map and output to stdout
../buildtools/sourcemapper ${errorOut} ${srcmap}
2022-08-13 20:33:44 +00:00
2022-08-14 05:54:07 +00:00
# delete the temporary files
rm ${errorOut}
rm ${progname}.ts
rm ${srcmap}