MCPcopy Create free account
hub / github.com/Silentely/eSIM-Tools / copyDirectory

Function copyDirectory

scripts/build-static.js:47–70  ·  view source on GitHub ↗
(source, destination)

Source from the content-addressed store, hash-verified

45}
46
47async function copyDirectory(source, destination) {
48 try {
49 await fs.promises.mkdir(destination, { recursive: true });
50 const entries = await fs.promises.readdir(source, { withFileTypes: true });
51
52 for (const entry of entries) {
53 const srcPath = path.join(source, entry.name);
54 const destPath = path.join(destination, entry.name);
55
56 try {
57 if (entry.isDirectory()) {
58 await copyDirectory(srcPath, destPath);
59 } else if (entry.isFile()) {
60 await fs.promises.copyFile(srcPath, destPath);
61 }
62 } catch (fileErr) {
63 console.warn(`⚠️ 跳过文件 ${entry.name}:`, fileErr.message);
64 // 继续处理其他文件
65 }
66 }
67 } catch (err) {
68 throw new Error(`复制目录失败 ${source}: ${err.message}`);
69 }
70}
71
72(async () => {
73 BuildLogger.log('🧹 清理 dist 目录...');

Callers 1

copyEntryFunction · 0.85

Calls 1

warnMethod · 0.45

Tested by

no test coverage detected