fix(mac): reject build-and-run wrapper args

This commit is contained in:
Vincent Koc 2026-06-20 21:36:01 +02:00
parent 803064c6e0
commit 63ac2e2ce0
No known key found for this signature in database
2 changed files with 45 additions and 1 deletions

View file

@ -1,6 +1,26 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/../apps/macos"
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
APP_DIR="$ROOT_DIR/apps/macos"
usage() {
printf 'Usage: %s\n' "$(basename "$0")"
printf 'Build, stop, and relaunch the local debug OpenClaw macOS app.\n'
}
for arg in "$@"; do
case "$arg" in
--help|-h)
usage
exit 0
;;
--) ;;
*) printf 'ERROR: Unknown build-and-run-mac option: %s\n' "$arg" >&2; exit 1 ;;
esac
done
cd "$APP_DIR"
BUILD_PATH=".build-local"
PRODUCT="OpenClaw"

View file

@ -108,9 +108,33 @@ afterEach(() => {
});
describe("scripts/build-and-run-mac.sh", () => {
it("prints help before build or launch side effects", () => {
const result = spawnSync("bash", [scriptPath, "--help"], {
cwd: process.cwd(),
encoding: "utf8",
});
expect(result.status).toBe(0);
expect(result.stdout).toContain("Usage: build-and-run-mac.sh");
expect(result.stdout).toContain("Build, stop, and relaunch");
expect(result.stderr).toBe("");
});
it("rejects unknown options before build or launch side effects", () => {
const result = spawnSync("bash", [scriptPath, "--wat"], {
cwd: process.cwd(),
encoding: "utf8",
});
expect(result.status).toBe(1);
expect(result.stdout).toBe("");
expect(result.stderr.trim()).toBe("ERROR: Unknown build-and-run-mac option: --wat");
});
it("keeps launch logs isolated unless an explicit log path is provided", () => {
const script = readFileSync(scriptPath, "utf8");
expect(script).toContain('cd "$APP_DIR"');
expect(script).toContain(
'LOG_PATH="${OPENCLAW_MAC_RUN_LOG:-$(mktemp "${TMPDIR:-/tmp}/openclaw-${PRODUCT}.XXXXXX.log")}"',
);