mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-07-23 21:01:00 +02:00
refactor: harden tests
This commit is contained in:
@@ -4,7 +4,10 @@ import { join, dirname } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const MANIFEST_DIR = dirname(fileURLToPath(import.meta.url));
|
||||
const PROFILE = process.env.PROFILE || "debug";
|
||||
const PROFILE =
|
||||
process.argv.includes("--release") || process.env.PROFILE === "release"
|
||||
? "release"
|
||||
: "debug";
|
||||
|
||||
function getTarget() {
|
||||
if (process.env.TARGET) return process.env.TARGET;
|
||||
@@ -48,32 +51,22 @@ function copyBinary(baseName) {
|
||||
if (isWindows) destName += ".exe";
|
||||
const dest = join(destDir, destName);
|
||||
|
||||
if (existsSync(source)) {
|
||||
copyFileSync(source, dest);
|
||||
console.log(`Copied ${binName} to ${dest}`);
|
||||
} else {
|
||||
console.log(`Warning: Binary not found at ${source}`);
|
||||
console.log(`Building ${baseName} binary...`);
|
||||
|
||||
const buildArgs = ["build", "--bin", baseName];
|
||||
if (PROFILE === "release") buildArgs.push("--release");
|
||||
if (TARGET !== "unknown" && TARGET !== HOST_TARGET) {
|
||||
buildArgs.push("--target", TARGET);
|
||||
}
|
||||
|
||||
execFileSync("cargo", buildArgs, {
|
||||
cwd: MANIFEST_DIR,
|
||||
stdio: "inherit",
|
||||
});
|
||||
|
||||
if (existsSync(source)) {
|
||||
copyFileSync(source, dest);
|
||||
console.log(`Built and copied ${binName} to ${dest}`);
|
||||
} else {
|
||||
console.error(`Error: Failed to build ${baseName} binary`);
|
||||
process.exit(1);
|
||||
}
|
||||
const buildArgs = ["build", "--bin", baseName];
|
||||
if (PROFILE === "release") buildArgs.push("--release");
|
||||
if (TARGET !== "unknown" && TARGET !== HOST_TARGET) {
|
||||
buildArgs.push("--target", TARGET);
|
||||
}
|
||||
execFileSync("cargo", buildArgs, {
|
||||
cwd: MANIFEST_DIR,
|
||||
stdio: "inherit",
|
||||
});
|
||||
|
||||
if (!existsSync(source)) {
|
||||
console.error(`Error: Failed to build ${baseName} binary`);
|
||||
process.exit(1);
|
||||
}
|
||||
copyFileSync(source, dest);
|
||||
console.log(`Built and copied ${binName} to ${dest}`);
|
||||
}
|
||||
|
||||
copyBinary("donut-proxy");
|
||||
|
||||
Reference in New Issue
Block a user