31 lines
1.2 KiB
JavaScript
31 lines
1.2 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
function walkDir(dir, callback) {
|
|
fs.readdirSync(dir).forEach(f => {
|
|
let dirPath = path.join(dir, f);
|
|
let isDirectory = fs.statSync(dirPath).isDirectory();
|
|
isDirectory ? walkDir(dirPath, callback) : callback(dirPath);
|
|
});
|
|
}
|
|
|
|
walkDir('apps/website/src/app/[lang]', (filePath) => {
|
|
if (filePath.endsWith('.tsx') || filePath.endsWith('.ts')) {
|
|
let content = fs.readFileSync(filePath, 'utf8');
|
|
|
|
let newContent = content.replace(/\/\/ lang is extracted from paramsexport/g, "// lang is extracted from params\nexport")
|
|
.replace(/\/\/ lang is extracted from paramsfunction/g, "// lang is extracted from params\nfunction")
|
|
.replace(/\/\/ lang is extracted from paramstype/g, "// lang is extracted from params\ntype")
|
|
.replace(/\/\/ lang is extracted from paramsconst/g, "// lang is extracted from params\nconst");
|
|
|
|
if (filePath.endsWith('layout.tsx')) {
|
|
newContent = newContent.replace("import './globals.css';", "import '../globals.css';");
|
|
}
|
|
|
|
if (newContent !== content) {
|
|
fs.writeFileSync(filePath, newContent, 'utf8');
|
|
console.log('Fixed syntax in', filePath);
|
|
}
|
|
}
|
|
});
|