-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
66 lines (56 loc) · 1.6 KB
/
Copy pathbuild.js
File metadata and controls
66 lines (56 loc) · 1.6 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const fs = require('fs');
const path = require('path');
const sourceDir = __dirname;
const destDir = path.join(__dirname, 'public');
// Create public directory
if (!fs.existsSync(destDir)) {
fs.mkdirSync(destDir);
}
// Files to copy directly
const filesToCopy = [
'index.html',
'app.html',
'landing.html',
'styles.css',
'script.js',
'manifest.json',
'sw.js',
'logo.png',
'Screenshot Desktop.png'
];
filesToCopy.forEach(file => {
const srcPath = path.join(sourceDir, file);
const destPath = path.join(destDir, file);
if (fs.existsSync(srcPath)) {
fs.copyFileSync(srcPath, destPath);
console.log(`Copied ${file} to public/`);
} else {
console.warn(`Warning: ${file} not found.`);
}
});
// Function to copy directory recursively
function copyDir(src, dest) {
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest);
}
const entries = fs.readdirSync(src, { withFileTypes: true });
for (let entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);
if (entry.isDirectory()) {
copyDir(srcPath, destPath);
} else {
fs.copyFileSync(srcPath, destPath);
}
}
}
// Copy icons folder if it exists
const iconsDir = path.join(sourceDir, 'icons');
const destIconsDir = path.join(destDir, 'icons');
if (fs.existsSync(iconsDir)) {
copyDir(iconsDir, destIconsDir);
console.log('Copied icons folder to public/');
} else {
console.warn('Warning: icons folder not found.');
}
console.log('Build completed successfully.');