MCPcopy
hub / github.com/electerm/electerm / cpRecursive

Function cpRecursive

src/app/lib/fs.js:121–132  ·  view source on GitHub ↗

* Recursive copy helper for Node.js < 16.7.0 (where fs.cp doesn't exist)

(src, dest)

Source from the content-addressed store, hash-verified

119 * Recursive copy helper for Node.js < 16.7.0 (where fs.cp doesn't exist)
120 */
121async function cpRecursive (src, dest) {
122 const stat = await fss.stat(src)
123 if (stat.isDirectory()) {
124 await fss.mkdir(dest, { recursive: true })
125 const entries = await fss.readdir(src)
126 for (const entry of entries) {
127 await cpRecursive(path.join(src, entry), path.join(dest, entry))
128 }
129 } else {
130 await fss.copyFile(src, dest)
131 }
132}
133
134/**
135 * cp from to

Callers 1

cpFunction · 0.85

Calls 3

copyFileMethod · 0.80
statMethod · 0.45
mkdirMethod · 0.45

Tested by

no test coverage detected