MCPcopy Create free account
hub / github.com/BabylonJS/BabylonReactNative / copyRecursive

Function copyRecursive

Package/setup_dev.js:12–34  ·  view source on GitHub ↗

* Recursively copy files and directories * @param {string} src - Source directory * @param {string} dest - Destination directory

(src, dest)

Source from the content-addressed store, hash-verified

10 * @param {string} dest - Destination directory
11 */
12function copyRecursive(src, dest) {
13 if (!fs.existsSync(src)) {
14 throw new Error(`Source directory ${src} does not exist`);
15 }
16
17 // Create destination directory if it doesn't exist
18 if (!fs.existsSync(dest)) {
19 fs.mkdirSync(dest, { recursive: true });
20 }
21
22 const entries = fs.readdirSync(src, { withFileTypes: true });
23
24 for (const entry of entries) {
25 const srcPath = path.join(src, entry.name);
26 const destPath = path.join(dest, entry.name);
27
28 if (entry.isDirectory()) {
29 copyRecursive(srcPath, destPath);
30 } else {
31 fs.copyFileSync(srcPath, destPath);
32 }
33 }
34}
35
36/**
37 * Execute a command in a specific directory

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected