-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostBuildTauri.cjs
49 lines (38 loc) · 1.14 KB
/
postBuildTauri.cjs
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
const fs = require("fs");
const path = require("path");
const rootPath = path.resolve(__dirname);
const releasePath = path.resolve(rootPath, "release");
const tauriBundlePath = path.resolve(
rootPath,
"src-tauri",
"target",
"release",
"bundle",
);
if (!fs.existsSync(tauriBundlePath)) {
console.error(`Bundle path ${tauriBundlePath} does not exist.`);
process.exit(1);
}
if (!fs.existsSync(releasePath)) {
fs.mkdirSync(releasePath);
}
// Copies all folders and files from src-tauri/target/release/bundle to release/bundle
const copyFiles = (src, dest) => {
const stats = fs.statSync(src);
if (stats.isDirectory()) {
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest);
}
fs.readdirSync(src).forEach((file) => {
copyFiles(path.resolve(src, file), path.resolve(dest, file));
});
} else {
// If it's a file, replace it
if (fs.existsSync(dest) && fs.statSync(dest).isFile()) {
fs.rmSync(dest);
}
fs.copyFileSync(src, dest);
console.log(`Copied ${src} to ${dest}`);
}
};
copyFiles(tauriBundlePath, releasePath);