-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathtauri-cli.mjs
More file actions
66 lines (55 loc) · 1.61 KB
/
tauri-cli.mjs
File metadata and controls
66 lines (55 loc) · 1.61 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
import { spawn } from "node:child_process";
import { existsSync, readdirSync, rmSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const repoRoot = path.resolve(__dirname, "..");
const args = process.argv.slice(2);
function isBundleCommand() {
return args[0] === "build" || args[0] === "bundle";
}
function cleanStaleDmgTempFiles() {
const macosBundleDir = path.join(repoRoot, "src-tauri", "target", "release", "bundle", "macos");
if (!existsSync(macosBundleDir)) return;
for (const entry of readdirSync(macosBundleDir)) {
if (/^rw\..+\.dmg$/.test(entry)) {
rmSync(path.join(macosBundleDir, entry), { force: true });
}
}
}
function hasConfigOverride() {
return args.some((arg) => arg === "--config" || arg === "-c" || arg.startsWith("--config="));
}
const env = { ...process.env };
if (isBundleCommand()) {
cleanStaleDmgTempFiles();
if (!env.TAURI_BUNDLER_DMG_IGNORE_CI) {
env.CI = "true";
}
if (!env.TAURI_SIGNING_PRIVATE_KEY && !hasConfigOverride()) {
args.push("--config", JSON.stringify({ bundle: { createUpdaterArtifacts: false } }));
}
}
const tauriCliScript = path.join(
repoRoot,
"node_modules",
"@tauri-apps",
"cli",
"tauri.js",
);
const child = spawn(process.execPath, [tauriCliScript, ...args], {
cwd: repoRoot,
env,
stdio: "inherit",
});
child.on("error", (error) => {
console.error(error);
process.exit(1);
});
child.on("exit", (code, signal) => {
if (signal) {
process.kill(process.pid, signal);
return;
}
process.exit(code ?? 1);
});