(srcDir, destDir, { noLinks = false } = {})
| 101 | * @param options Options for copying, including noLinks to exclude symbolic links. |
| 102 | */ |
| 103 | const copyDirContents = async (srcDir, destDir, { noLinks = false } = {}) => { |
| 104 | const entries = await fsp.readdir(srcDir, { withFileTypes: true }) |
| 105 | |
| 106 | await fsp.mkdir(destDir, { recursive: true }) |
| 107 | |
| 108 | for (const entry of entries) { |
| 109 | const srcPath = path.join(srcDir, entry.name) |
| 110 | const destPath = path.join(destDir, entry.name) |
| 111 | |
| 112 | if (noLinks && entry.isSymbolicLink()) { |
| 113 | continue |
| 114 | } |
| 115 | |
| 116 | if (entry.isDirectory()) { |
| 117 | await copyDirContents(srcPath, destPath, { noLinks }) |
| 118 | } else { |
| 119 | await fsp.copyFile(srcPath, destPath) |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Recursively removes a file or directory. |
no outgoing calls
no test coverage detected
searching dependent graphs…