Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

Fix tests on macos

fzaninotto82c4dbd33f15
diff --git a/.claude/hooks/lib/context.mjs b/.claude/hooks/lib/context.mjs
index 990bb61d..205c2dc8 100644
--- a/.claude/hooks/lib/context.mjs
+++ b/.claude/hooks/lib/context.mjs
@@ -7,7 +7,7 @@
import { appendFileSync, existsSync, mkdirSync, rmSync } from "node:fs";
import { basename, dirname, isAbsolute, join } from "node:path";
import { decisionBlock } from "./io.mjs";
-import { REPO, TMP_ROOT, sanitizePath } from "./paths.mjs";
+import { REPO, TMP_ROOT, canonicalPath, sanitizePath } from "./paths.mjs";
import { exec } from "./process.mjs";
import { loadConfig, worktreeProvision } from "./config.mjs";
@@ -125,7 +125,7 @@ export function createHookContext(input, name = "hook") {
agentId,
sessionShort,
sessionDir,
- worktreeBase: sessionDir,
+ worktreeBase: canonicalPath(sessionDir),
logFile,
ticketsDir: process.env.TICKETS_DIR || join(sessionDir, "tickets"),
diff --git a/.claude/hooks/lib/paths.mjs b/.claude/hooks/lib/paths.mjs
index e1c3bf42..a0682885 100644
--- a/.claude/hooks/lib/paths.mjs
+++ b/.claude/hooks/lib/paths.mjs
@@ -1,4 +1,5 @@
-import { join } from "node:path";
+import { realpathSync } from "node:fs";
+import { basename, dirname, join } from "node:path";
import { exec } from "./process.mjs";
// APP_DIR / CLAUDE_PROJECT_DIR override the detected root (used by hook tests).
@@ -22,3 +23,15 @@ export const TMP_ROOT =
export function sanitizePath(p) {
return String(p ?? "").replace(/\//g, "_");
}
+
+// Resolve symlinks in the deepest existing ancestor of `p` (which may not exist
+// yet). Git records worktree paths canonicalized, so on macOS a `/tmp/...` or
+// `/var/folders/...` base must become `/private/...` to match `git worktree list`.
+export function canonicalPath(p) {
+ try {
+ return realpathSync(p);
+ } catch {
+ const parent = dirname(p);
+ return parent === p ? p : join(canonicalPath(parent), basename(p));
+ }
+}
diff --git a/.claude/hooks/test/e2e-on-feature-review.test.mjs b/.claude/hooks/test/e2e-on-feature-review.test.mjs
index ebcce221..d13f702a 100644
--- a/.claude/hooks/test/e2e-on-feature-review.test.mjs
+++ b/.claude/hooks/test/e2e-on-feature-review.test.mjs
@@ -11,7 +11,7 @@ import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { afterEach, beforeEach, describe, expect, test } from "vitest";
-import { sanitizePath } from "../lib/paths.mjs";
+import { canonicalPath, sanitizePath } from "../lib/paths.mjs";
const HERE = dirname(fileURLToPath(import.meta.url));
const HOOK = join(HERE, "..", "e2e-on-feature-review.mjs");
@@ -107,7 +107,7 @@ describe("e2e-on-feature-review", () => {
const r = run(transcriptWithMeta("Feature-review: add deal importance"));
expect(r.status).toBe(0);
const ranWith = readFileSync(join(APP_DIR, "ran-with-src"), "utf8").trim();
- expect(ranWith).toBe(join(sessionDir, "_session"));
+ expect(ranWith).toBe(canonicalPath(join(sessionDir, "_session")));
});
test("records a passing suite", () => {