remove-prettier-ignore.mjs 577 B

12345678910111213141516171819202122232425
  1. // remove-prettier-ignore.js
  2. import { readFileSync, writeFileSync } from 'fs';
  3. import { sync } from 'glob';
  4. const patterns = [
  5. /\/\/ prettier-ignore[\s]*/g,
  6. ];
  7. sync('dist/**/*.html').forEach(file => {
  8. let content = readFileSync(file, 'utf8');
  9. let modified = false;
  10. patterns.forEach(pattern => {
  11. const newContent = content.replace(pattern, '');
  12. if (newContent !== content) {
  13. content = newContent;
  14. modified = true;
  15. }
  16. });
  17. if (modified) {
  18. writeFileSync(file, content);
  19. console.log(`Cleaned: ${file}`);
  20. }
  21. });