try not to always build

This commit is contained in:
Chris Wanstrath 2025-10-07 20:43:00 -07:00
parent b3848c35ee
commit b6c0dde776

View File

@ -1,8 +1,23 @@
#!/bin/sh
SHA=$(git rev-parse --short HEAD)
# Build to a temporary file
bun build ./src/js/main.js \
--outfile ./public/bundle.js \
--outfile ./public/bundle.tmp.js \
--target browser
printf "////\n// version: %s\n\n" "$SHA" | cat - ./public/bundle.js > ./public/bundle.tmp.js
mv ./public/bundle.tmp.js ./public/bundle.js
# If bundle.js doesn't exist yet, fake it it
if [ ! -f ./public/bundle.js ]; then
touch ./public/bundle.js
fi
# Strip version comments from both files and compare
tail -n +4 ./public/bundle.js > ./public/bundle.old.content.tmp
tail -n +1 ./public/bundle.tmp.js > ./public/bundle.new.content.tmp
if ! cmp -s ./public/bundle.old.content.tmp ./public/bundle.new.content.tmp; then
printf "////\n// version: %s\n\n" "$SHA" | cat - ./public/bundle.tmp.js > ./public/bundle.js
fi
rm ./public/bundle.tmp.js ./public/bundle.old.content.tmp ./public/bundle.new.content.tmp