2
0
mirror of https://github.com/iconify/iconify.git synced 2024-09-21 01:39:00 +00:00
iconify/components/react/cleanup.js

27 lines
692 B
JavaScript
Raw Normal View History

2024-05-28 19:20:42 +00:00
import { readFileSync, writeFileSync } from 'node:fs';
// Text to ad
const text = "'use client'";
// List of files to fix
['iconify', 'offline'].forEach((prefix) => {
2024-05-24 14:26:41 +00:00
// Add 'use client' to files
['js', 'cjs', 'mjs'].forEach((ext) => {
const file = `dist/${prefix}.${ext}`;
try {
const content = readFileSync(file, 'utf8');
if (!content.startsWith(text)) {
2024-05-28 19:20:42 +00:00
writeFileSync(file, text + ';\n\n' + content, 'utf8');
console.log('Added client only statement to ' + file);
}
} catch {
//
}
});
2024-05-24 14:26:41 +00:00
// Copy .d.ts to .d.mts
const source = `dist/${prefix}.d.ts`;
2024-05-28 19:20:42 +00:00
const target = `dist/${prefix}.d.cts`;
2024-05-24 14:26:41 +00:00
writeFileSync(target, readFileSync(source, 'utf8'), 'utf8');
});