* Recursively copy a file or directory. * * @param src The source directory. * @param dest The destination to copy src to.
(src: string, dest: string)
| 204 | * @param dest The destination to copy src to. |
| 205 | */ |
| 206 | function copyRecursive(src: string, dest: string) { |
| 207 | // Avoid 'cp -r', which Windows does not suppport |
| 208 | const stat = fs.lstatSync(src); |
| 209 | if (stat.isFile()) { |
| 210 | fs.copyFileSync(src, dest); |
| 211 | } else if (stat.isDirectory()) { |
| 212 | const contents = fs.readdirSync(src); |
| 213 | fs.mkdirSync(dest); |
| 214 | for (let name of contents) { |
| 215 | copyRecursive(path.join(src, name), |
| 216 | path.join(dest, name)); |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Map a function on all files and directories under a path. |