Skip to content
Snippets Groups Projects
Verified Commit 6c708be2 authored by Zandor Smith's avatar Zandor Smith :computer:
Browse files

Code style improvement of script 4.

parent 40f6f91e
No related branches found
No related tags found
No related merge requests found
......@@ -18,28 +18,29 @@ async function processFilesInDirectory(directory) {
continue;
}
if (file.isFile()) {
const filePath = `${directory}${file.name}`;
let fileContent = fs.readFileSync(filePath, "utf8");
let madeChanges = false;
if(fileContent.includes("REACT_APP_")) {
console.log("Replace 'REACT_APP_' with 'VITE_' in", filePath);
fileContent = fileContent.replaceAll("REACT_APP_", "VITE_");
madeChanges = true;
}
if((filePath.endsWith(".js") || filePath.endsWith(".jsx")) && fileContent.includes("process.env")) {
console.log("Replace 'process.env' with 'import.meta.env' in", filePath);
fileContent = fileContent.replaceAll("process.env", "import.meta.env");
madeChanges = true;
}
if(!madeChanges) {
continue;
}
fs.writeFileSync(filePath, fileContent);
if (!file.isFile()) {
continue;
}
const filePath = `${directory}${file.name}`;
let fileContent = fs.readFileSync(filePath, "utf8");
let madeChanges = false;
if(fileContent.includes("REACT_APP_")) {
console.log("Replace 'REACT_APP_' with 'VITE_' in", filePath);
fileContent = fileContent.replaceAll("REACT_APP_", "VITE_");
madeChanges = true;
}
if((filePath.endsWith(".js") || filePath.endsWith(".jsx")) && fileContent.includes("process.env")) {
console.log("Replace 'process.env' with 'import.meta.env' in", filePath);
fileContent = fileContent.replaceAll("process.env", "import.meta.env");
madeChanges = true;
}
if(!madeChanges) {
continue;
}
fs.writeFileSync(filePath, fileContent);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment