30 lines
1.0 KiB
JavaScript
30 lines
1.0 KiB
JavaScript
import { mkdirSync } from "node:fs";
|
|
import { spawnSync } from "node:child_process";
|
|
import { dirname, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
const bun = process.env.BUN_BIN || "bun";
|
|
const output = resolve(root, "dist/bin/seal-home");
|
|
|
|
mkdirSync(dirname(output), { recursive: true });
|
|
run(bun, ["build", "--compile", "--outfile", output, "src/cli.ts"]);
|
|
|
|
// Bun's macOS standalone output can carry a stale code-signature blob on
|
|
// development machines. Re-signing ad hoc keeps the local binary executable.
|
|
if (process.platform === "darwin") {
|
|
run("/usr/bin/codesign", ["--remove-signature", output]);
|
|
run("/usr/bin/codesign", ["--force", "--sign", "-", output]);
|
|
}
|
|
|
|
function run(command, args) {
|
|
const result = spawnSync(command, args, {
|
|
cwd: root,
|
|
stdio: "inherit"
|
|
});
|
|
if (result.error) throw result.error;
|
|
if (result.status !== 0) {
|
|
throw new Error(`${command} ${args.join(" ")} failed with status ${result.status}`);
|
|
}
|
|
}
|