sync-chrome-dist.mjs

910 B · raw

1import { existsSync, mkdirSync } from "node:fs";2import { execSync } from "node:child_process";3import path from "node:path";4import { fileURLToPath } from "node:url";56const __filename = fileURLToPath(import.meta.url);7const __dirname = path.dirname(__filename);8const rootDir = path.resolve(__dirname, "..");9const sourceDir = path.join(rootDir, "dist-chrome");10const targetDir = path.join(rootDir, "dist");1112if (!existsSync(sourceDir)) {13  console.error(`Chrome build output not found: ${sourceDir}`);14  process.exit(1);15}1617// Use shell cp -r to avoid EACCES on mounted filesystems (cpSync fails on stale files)18mkdirSync(targetDir, { recursive: true });19try {20  execSync(`cp -r ${sourceDir}/. ${targetDir}/`, { stdio: "pipe" });21} catch {22  // Permission warnings on unchanged stale files are non-fatal23}2425console.log(`Synced ${path.relative(rootDir, sourceDir)} -> ${path.relative(rootDir, targetDir)}`);