// Fails if any image in dist/ still carries EXIF location or capture time. // Runs after the build in CI, so a leaking original never gets released. import { existsSync, readdirSync, readFileSync } from 'node:fs'; import exifr from 'exifr'; const dir = new URL('../dist/_astro/', import.meta.url); const leaking = []; for (const file of (existsSync(dir) ? readdirSync(dir) : []).filter((f) => /\.(jpe?g|png|webp|avif)$/i.test(f))) { // exifr chokes on file paths under Node 26, a buffer works const exif = await exifr.parse(readFileSync(new URL(file, dir)), true).catch(() => undefined); if (exif?.latitude !== undefined || exif?.GPSLatitude || exif?.DateTimeOriginal) leaking.push(file); } if (leaking.length) { console.error(`images with EXIF location/time in dist/_astro:\n ${leaking.join('\n ')}`); process.exit(1); } console.log('no EXIF location/time in published images');