Skip to content

Commit 54fb61a

Browse files
Updated the copy command
1 parent 209ab82 commit 54fb61a

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

modelina-website/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"build:resources": "npm run build:examples && npm run build:docs && npm run copy:docs:img",
1313
"build:examples": "node scripts/build-examples.js",
1414
"build:docs": "node scripts/build-docs.js",
15-
"copy:docs:img": "cp -r ../docs/img public/img/docs"
15+
"copy:docs:img": "node scripts/copy-docs-img.js"
1616
},
1717
"dependencies": {
1818
"@monaco-editor/react": "^4.6.0",
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const path = require('path');
2+
const fs = require('fs');
3+
4+
const SOURCE_PATH = path.join(__dirname, '../../docs/img');
5+
const DEST_PATH = path.join(__dirname, '../public/img/docs');
6+
7+
/**
8+
* Recursively copy a directory (cross-platform)
9+
*/
10+
function copyDirSync(src, dest) {
11+
// Create destination directory if it doesn't exist
12+
if (!fs.existsSync(dest)) {
13+
fs.mkdirSync(dest, { recursive: true });
14+
}
15+
16+
const entries = fs.readdirSync(src, { withFileTypes: true });
17+
18+
for (const entry of entries) {
19+
const srcPath = path.join(src, entry.name);
20+
const destPath = path.join(dest, entry.name);
21+
22+
if (entry.isDirectory()) {
23+
copyDirSync(srcPath, destPath);
24+
} else {
25+
fs.copyFileSync(srcPath, destPath);
26+
}
27+
}
28+
}
29+
30+
/**
31+
* Copy docs images to public folder in a cross-platform way
32+
*/
33+
function copyDocsImages() {
34+
try {
35+
copyDirSync(SOURCE_PATH, DEST_PATH);
36+
console.log('Images copied successfully!');
37+
} catch (err) {
38+
console.error('Error copying images:', err);
39+
process.exit(1);
40+
}
41+
}
42+
43+
copyDocsImages();

0 commit comments

Comments
 (0)