import { copyFileSync, mkdirSync, existsSync } from 'node:fs'; import { readFileSync } from 'node:fs'; import { join, dirname } from 'node:path'; import { fileURLToPath } from 'node:url'; const root = join(dirname(fileURLToPath(import.meta.url)), '..'); const map = JSON.parse(readFileSync(join(root, 'scripts/asset-map.json'), 'utf8')); let n = 0, missing = 0; for (const [destDir, entries] of Object.entries(map)) { mkdirSync(join(root, destDir), { recursive: true }); for (const [src, dest] of Object.entries(entries)) { const from = join(root, 'assets-src', src); if (!existsSync(from)) { console.error(`MANCANTE: ${src}`); missing++; continue; } copyFileSync(from, join(root, destDir, dest)); n++; } } console.log(`Copiate ${n} immagini${missing ? `, ${missing} mancanti` : ''}`); process.exit(missing ? 1 : 0);