copy-divoom-assets.ts 806 B

1234567891011121314151617181920212223
  1. import { copyFileSync, mkdirSync, readdirSync, rmSync } from 'node:fs';
  2. import path from 'node:path';
  3. import { fileURLToPath } from 'node:url';
  4. const __dirname = path.dirname(fileURLToPath(import.meta.url));
  5. const repoRoot = path.resolve(__dirname, '..');
  6. const sourceDir = path.join(repoRoot, 'src', 'divoom');
  7. const outputDir = path.join(repoRoot, 'dist', 'divoom');
  8. rmSync(outputDir, { recursive: true, force: true });
  9. mkdirSync(outputDir, { recursive: true });
  10. let copied = 0;
  11. for (const entry of readdirSync(sourceDir, { withFileTypes: true })) {
  12. if (!entry.isFile() || !entry.name.endsWith('.gif')) continue;
  13. copyFileSync(
  14. path.join(sourceDir, entry.name),
  15. path.join(outputDir, entry.name),
  16. );
  17. copied += 1;
  18. }
  19. console.log(`✅ Copied ${copied} Divoom GIF assets to ${outputDir}`);