MCPcopy Create free account
hub / github.com/anus-dev/ANUS / copyFilesRecursive

Function copyFilesRecursive

scripts/copy_files.js:33–50  ·  view source on GitHub ↗
(source, target)

Source from the content-addressed store, hash-verified

31const extensionsToCopy = ['.md', '.json', '.sb'];
32
33function copyFilesRecursive(source, target) {
34 if (!fs.existsSync(target)) {
35 fs.mkdirSync(target, { recursive: true });
36 }
37
38 const items = fs.readdirSync(source, { withFileTypes: true });
39
40 for (const item of items) {
41 const sourcePath = path.join(source, item.name);
42 const targetPath = path.join(target, item.name);
43
44 if (item.isDirectory()) {
45 copyFilesRecursive(sourcePath, targetPath);
46 } else if (extensionsToCopy.includes(path.extname(item.name))) {
47 fs.copyFileSync(sourcePath, targetPath);
48 }
49 }
50}
51
52if (!fs.existsSync(sourceDir)) {
53 console.error(`Source directory ${sourceDir} not found.`);

Callers 1

copy_files.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected