From b6c0dde776e1c7884f445f22b9a09634311531aa Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Tue, 7 Oct 2025 20:43:00 -0700 Subject: [PATCH] try not to always build --- scripts/build.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 75a2c87..55a3dbe 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -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 \ No newline at end of file