dsql-admin/dsql-app/utils/findAndReplace.ts

28 lines
602 B
TypeScript
Raw Normal View History

2024-11-05 11:12:42 +00:00
// @ts-check
2025-01-13 08:00:21 +00:00
import fs from "fs";
import path from "path";
2024-11-05 11:12:42 +00:00
const ignorePattern = /node_modules/;
const searchMatchPattern = {
pattern: /\"\/admin\/(.*?)\"/,
replace: "'/b/$1'",
};
/**
*
* @param {object} param0
* @param {string} param0.dir
*/
2025-01-13 08:00:21 +00:00
function replaceDir({ dir }: { dir: string }) {
2024-11-05 11:12:42 +00:00
const dirContent = fs.readdirSync(dir);
dirContent.forEach((fileFolder, index) => {
const fileFolderPath = path.join(dir, fileFolder);
const fsStat = fs.statSync(fileFolderPath);
if (!fsStat.isFile()) {
return replaceDir({ dir });
}
});
}