ported all templates to json
This commit is contained in:
28
fix_bom.cjs
Normal file
28
fix_bom.cjs
Normal file
@@ -0,0 +1,28 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const rootDir = 'd:\\gdfhbfgdbnbdfbdf\\typogenie\\src-tauri\\templates';
|
||||
|
||||
function walk(dir) {
|
||||
const files = fs.readdirSync(dir, { withFileTypes: true });
|
||||
files.forEach(dirent => {
|
||||
const fullPath = path.join(dir, dirent.name);
|
||||
if (dirent.isDirectory()) {
|
||||
walk(fullPath);
|
||||
} else if (dirent.name.endsWith('.json')) {
|
||||
let content = fs.readFileSync(fullPath, 'utf8');
|
||||
// Remove BOM
|
||||
if (content.charCodeAt(0) === 0xFEFF) {
|
||||
content = content.slice(1);
|
||||
console.log(`Cleaned BOM: ${fullPath}`);
|
||||
}
|
||||
// Trim whitespace
|
||||
content = content.trim();
|
||||
fs.writeFileSync(fullPath, content, { encoding: 'utf8' });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
walk(rootDir);
|
||||
console.log('Finished cleaning BOMs and trimming JSON files.');
|
||||
|
||||
Reference in New Issue
Block a user