-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsidecar-builder.js
More file actions
58 lines (40 loc) · 1.37 KB
/
sidecar-builder.js
File metadata and controls
58 lines (40 loc) · 1.37 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
import { execSync } from "child_process";
import fs from "fs";
import path from "path";
import os from "os";
console.log("building app");
execSync("npm run build:server");
const ext = process.platform == "win32" ? ".exe" : "";
const rustInfo = execSync('rustc -vV');
const targetTriple = /host: (\S+)/g.exec(rustInfo)[1];
if (!targetTriple) {
console.error("failed to determine platform target triple");
}
const distPath = path.join("./", "server", "dist");
const distFiles = fs.readdirSync(distPath);
const currentOs = os.platform();
let pattern = '';
if (currentOs == "win32") {
pattern = "win"
} else {
pattern = currentOs;
}
const binariesFileName = distFiles.filter(file => file.includes(pattern))[0]
const binariesDir = path.join("./", "src-tauri", "binaries");
console.log(`checking for binaries`);
// Check and create directory if it doesn't exist
try {
if (!fs.existsSync(binariesDir)) {
fs.mkdirSync(binariesDir, { recursive: true });
console.log(`Created directory: ${binariesDir}`);
} else {
console.log(`Directory already exists: ${binariesDir}`);
}
} catch (err) {
console.error(`Error creating directory: ${err}`);
}
console.log(`copying server binary to binaries directory`);
fs.copyFileSync(
path.join("./", "server", "dist", binariesFileName),
path.join(binariesDir, `server-${targetTriple}${ext}`)
);