import { existsSync, mkdirSync } from "node:fs"; import { execSync } from "node:child_process"; import path from "node:path"; import { fileURLToPath } from "node:url"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const rootDir = path.resolve(__dirname, ".."); const sourceDir = path.join(rootDir, "dist-chrome"); const targetDir = path.join(rootDir, "dist"); if (!existsSync(sourceDir)) { console.error(`Chrome build output not found: ${sourceDir}`); process.exit(1); } // Use shell cp -r to avoid EACCES on mounted filesystems (cpSync fails on stale files) mkdirSync(targetDir, { recursive: true }); try { execSync(`cp -r ${sourceDir}/. ${targetDir}/`, { stdio: "pipe" }); } catch { // Permission warnings on unchanged stale files are non-fatal } console.log(`Synced ${path.relative(rootDir, sourceDir)} -> ${path.relative(rootDir, targetDir)}`);