mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-10-13 18:22:13 +08:00
22 lines
802 B
JavaScript
22 lines
802 B
JavaScript
import { copyFileSync, mkdirSync, readdirSync } from 'node:fs';
|
|
import { dirname, join } from 'node:path';
|
|
|
|
export function copyTplFiles(srcDir, dstDir) {
|
|
function walk(currentSrc, currentDst) {
|
|
readdirSync(currentSrc, { withFileTypes: true }).forEach((dirent) => {
|
|
const srcPath = join(currentSrc, dirent.name);
|
|
const dstPath = join(currentDst, dirent.name);
|
|
|
|
if (dirent.isDirectory()) {
|
|
walk(srcPath, dstPath);
|
|
}
|
|
else if (dirent.isFile() && dirent.name.endsWith('.tpl')) {
|
|
mkdirSync(dirname(dstPath), { recursive: true });
|
|
copyFileSync(srcPath, dstPath);
|
|
console.log(`Copied: ${srcPath} -> ${dstPath}`);
|
|
}
|
|
});
|
|
}
|
|
walk(srcDir, dstDir);
|
|
}
|