(srcDir: string, destDir: string)
| 244 | } |
| 245 | |
| 246 | const validateSkillTree = (srcDir: string, destDir: string): void => { |
| 247 | for (const entry of readdirSync(srcDir, { withFileTypes: true })) { |
| 248 | const srcPath = join(srcDir, entry.name) |
| 249 | const destPath = join(destDir, entry.name) |
| 250 | const destStat = lstatIfExists(destPath) |
| 251 | if (destStat?.isSymbolicLink()) |
| 252 | throw new Error(`Refusing to write through symlink at ${destPath}`) |
| 253 | if (entry.isDirectory()) { |
| 254 | if (destStat && !destStat.isDirectory()) { |
| 255 | throw new Error( |
| 256 | `Cannot create directory at ${destPath}: path exists and is not a directory` |
| 257 | ) |
| 258 | } |
| 259 | validateSkillTree(srcPath, destPath) |
| 260 | } else if (entry.isFile() && destStat && !destStat.isFile()) { |
| 261 | throw new Error( |
| 262 | `Cannot write file at ${destPath}: path exists and is not a regular file` |
| 263 | ) |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | const copySkillTree = (srcDir: string, destDir: string): void => { |
| 269 | for (const entry of readdirSync(srcDir, { withFileTypes: true })) { |
no test coverage detected