-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsync-resources.js
More file actions
36 lines (30 loc) · 1.04 KB
/
sync-resources.js
File metadata and controls
36 lines (30 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const fs = require('fs');
const path = require('path');
// Use absolute paths
const sourceDir = path.resolve(__dirname, './resources');
const targetDir = path.resolve(__dirname, './website/docs');
console.log('Source Directory:', sourceDir);
console.log('Target Directory:', targetDir);
function syncResources(source, target) {
if (!fs.existsSync(source)) {
console.error(`Source directory "${source}" does not exist.`);
process.exit(1);
}
fs.readdirSync(source, { withFileTypes: true }).forEach((entry) => {
const sourcePath = path.join(source, entry.name);
const targetPath = path.join(target, entry.name);
if (entry.isDirectory()) {
if (!fs.existsSync(targetPath)) {
fs.mkdirSync(targetPath, { recursive: true });
}
syncResources(sourcePath, targetPath);
} else {
fs.copyFileSync(sourcePath, targetPath);
}
});
}
if (!fs.existsSync(targetDir)) {
fs.mkdirSync(targetDir, { recursive: true });
}
syncResources(sourceDir, targetDir);
console.log('✅ Resources synced successfully!');