fix(mac): isolate build run logs

This commit is contained in:
Vincent Koc
2026-06-02 04:41:55 +02:00
parent b2a55a282a
commit 674bd6fc93
2 changed files with 20 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ cd "$(dirname "$0")/../apps/macos"
BUILD_PATH=".build-local"
PRODUCT="OpenClaw"
BIN="$BUILD_PATH/debug/$PRODUCT"
LOG_PATH="${OPENCLAW_MAC_RUN_LOG:-$(mktemp "${TMPDIR:-/tmp}/openclaw-${PRODUCT}.XXXXXX.log")}"
printf "\n▶ Building $PRODUCT (debug, build path: $BUILD_PATH)\n"
swift build -c debug --product "$PRODUCT" --build-path "$BUILD_PATH"
@@ -13,6 +14,6 @@ printf "\n⏹ Stopping existing $PRODUCT...\n"
killall -q "$PRODUCT" 2>/dev/null || true
printf "\n🚀 Launching $BIN ...\n"
nohup "$BIN" >/tmp/openclaw.log 2>&1 &
nohup "$BIN" >"$LOG_PATH" 2>&1 &
PID=$!
printf "Started $PRODUCT (PID $PID). Logs: /tmp/openclaw.log\n"
printf "Started $PRODUCT (PID $PID). Logs: $LOG_PATH\n"

View File

@@ -0,0 +1,17 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
const scriptPath = "scripts/build-and-run-mac.sh";
describe("scripts/build-and-run-mac.sh", () => {
it("keeps launch logs isolated unless an explicit log path is provided", () => {
const script = readFileSync(scriptPath, "utf8");
expect(script).toContain(
'LOG_PATH="${OPENCLAW_MAC_RUN_LOG:-$(mktemp "${TMPDIR:-/tmp}/openclaw-${PRODUCT}.XXXXXX.log")}"',
);
expect(script).toContain('nohup "$BIN" >"$LOG_PATH" 2>&1 &');
expect(script).toContain('printf "Started $PRODUCT (PID $PID). Logs: $LOG_PATH\\n"');
expect(script).not.toContain("/tmp/openclaw.log");
});
});