Repository navigation
Expand file tree
/
Copy pathsync.js
More file actions
36 lines (31 loc) · 1.44 KB
/
Copy pathsync.js
File metadata and controls
36 lines (31 loc) · 1.44 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');
function copyRecursiveSync(src, dest, exclude) {
const exists = fs.existsSync(src);
const stats = exists && fs.statSync(src);
const isDirectory = exists && stats.isDirectory();
if (isDirectory) {
if (exclude.includes(path.basename(src))) return;
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest, { recursive: true });
}
fs.readdirSync(src).forEach(function (childItemName) {
copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName), exclude);
});
} else {
if (src.endsWith('.gz')) return; // Never copy compressed assets to cordova
fs.copyFileSync(src, dest);
}
}
const excludes = ['node_modules', 'cordova', '.git', 'package.json', 'package-lock.json', 'sync.js', '.vscode', '.gemini', 'dist', 'android-build.log', 'android-crash.log', 'android_build_verbose.log', 'run_android_last.log', 'run_android_final.log'];
const srcPath = path.resolve(__dirname);
const destPath = path.join(__dirname, 'cordova', 'www');
// Ensure destination exists
if (!fs.existsSync(destPath)) fs.mkdirSync(destPath, { recursive: true });
// Copy all top-level files except excludes
fs.readdirSync(srcPath).forEach(item => {
if (!excludes.includes(item)) {
copyRecursiveSync(path.join(srcPath, item), path.join(destPath, item), excludes);
}
});
console.log("Copied web UI to cordova/www");