#!/bin/bash
bm="$(dirname "$0")";
data="$bm/internal/static/";
jslib="$(realpath "$bm/../../../jslib/")";
jslibJS="$jslib/lib.js/";
tmpFile="$(mktemp)";
(
cd "$data";
for lib in lib/*.js; do
if [ "$lib" = "lib/html.js" -o "$lib" = "lib/svg.js" ]; then
continue;
fi;
source="$jslibJS/$(basename "$lib")";
if [ "$lib" -nt "$source" -o "$lib" -ot "$source" ]; then
cp -f --preserve=timestamps "$source" "$lib";
fi;
done;
$jslib/html.sh "$($jslib/requiredHTML.sh script.js)" lib/html.js;
$jslib/svg.sh "$($jslib/requiredSVG.sh script.js)" lib/svg.js;
head -n5 index.html | tr -d '\n ';
echo -n "";
tail -n5 index.html | tr -d '\n ';
) > "$tmpFile";
if [ "$1" = "-size" ]; then
stat -c %s "$tmpFile";
rm -f "$tmpFile";
exit 0;
fi;
cat > index.go < index.gz;
rm -f "$tmpFile";