| 29 | const extensionsToCopy = ['.md', '.json', '.sb']; |
| 30 | |
| 31 | function copyFilesRecursive(source, target) { |
| 32 | if (!fs.existsSync(target)) { |
| 33 | fs.mkdirSync(target, { recursive: true }); |
| 34 | } |
| 35 | |
| 36 | const items = fs.readdirSync(source, { withFileTypes: true }); |
| 37 | |
| 38 | for (const item of items) { |
| 39 | const sourcePath = path.join(source, item.name); |
| 40 | const targetPath = path.join(target, item.name); |
| 41 | |
| 42 | if (item.isDirectory()) { |
| 43 | copyFilesRecursive(sourcePath, targetPath); |
| 44 | } else if (extensionsToCopy.includes(path.extname(item.name))) { |
| 45 | fs.copyFileSync(sourcePath, targetPath); |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | if (!fs.existsSync(sourceDir)) { |
| 51 | console.error(`Source directory ${sourceDir} not found.`); |