// Copies the frontend's build output, dist/ (from npm run build), to // ../internal/frontend/dist/, which the backend embeds, so the next Go build // of job-search serves this frontend: // // npm run build && npm run sync // // The old copy is replaced entirely, so files from an earlier build don't // linger. Its .gitkeep, the only file there that's committed, is put back: // Go can't embed a directory that doesn't exist. import { cpSync, existsSync, rmSync, writeFileSync } from 'node:fs'; const source = 'dist'; const target = '../internal/frontend/dist'; if (!existsSync(`${source}/index.html`)) { console.error(`${source}/index.html not found: run npm run build first`); process.exit(1); } rmSync(target, { recursive: true, force: true }); cpSync(source, target, { recursive: true }); writeFileSync(`${target}/.gitkeep`, ''); console.log(`Copied ${source}/ to ${target}/`);