import { join } from 'node:path' import { copyFileSync, existsSync, mkdirSync, readdirSync, statSync } from 'fs-extra' import { getPackageInfo, isPackageExists, } from 'local-pkg' const patchesFolderPath = join(__dirname, './') // Path to the patches folder function copyDirectory(sourceDir: string, targetDir: string) { // 确保目标目录存在 if (!existsSync(targetDir)) { mkdirSync(targetDir, { recursive: true }) } // 读取源目录的内容 const entries = readdirSync(sourceDir) for (const entry of entries) { const sourcePath = join(sourceDir, entry) const targetPath = join(targetDir, entry) // 判断是文件还是目录 if (statSync(sourcePath).isDirectory()) { // 递归复制子目录 copyDirectory(sourcePath, targetPath) } else { // 复制文件 copyFileSync(sourcePath, targetPath) } } } if (isPackageExists('ant-design-vue')) { void getPackageInfo('ant-design-vue').then((info) => { const targetPath = info!.rootPath copyDirectory(`${patchesFolderPath}/ant-design-vue`, targetPath) }) }