corretorimoveis01/Template-02/replace.ts

30 lines
763 B
TypeScript
Raw Permalink Normal View History

2026-05-15 14:35:38 +00:00
import * as fs from 'fs';
import * as path from 'path';
function replaceStone(filePath: string) {
let content = fs.readFileSync(filePath, 'utf8');
let original = content;
content = content.replace(/zinc-/g, "stone-");
if (content !== original) {
fs.writeFileSync(filePath, content, 'utf8');
console.log('Updated stone in ' + filePath);
}
}
function processDirectory(dir: string) {
const files = fs.readdirSync(dir);
for (const file of files) {
const fullPath = path.join(dir, file);
const stat = fs.statSync(fullPath);
if (stat.isDirectory()) {
processDirectory(fullPath);
} else if (fullPath.endsWith('.tsx') || fullPath.endsWith('.ts')) {
replaceStone(fullPath);
}
}
}
processDirectory('./src');