@@ -1,5 +1,11 @@
11 import { afterEach, beforeEach, describe, expect, test } from "bun:test";
2-import { mkdirSync, rmSync, writeFileSync } from "node:fs";
2+import {
3+ lstatSync,
4+ mkdirSync,
5+ realpathSync,
6+ rmSync,
7+ writeFileSync,
8+} from "node:fs";
39 import { tmpdir } from "node:os";
410 import { join } from "node:path";
511 import {
@@ -7,6 +13,7 @@ import {
713 cleanupBranch,
814 createWorktree,
915 hasDirtyWorkingTree,
16+ initializeWorktree,
1017 isGitRepo,
1118 mergeWorktree,
1219 removeWorktree,
@@ -115,6 +122,35 @@ describe("worktree helpers", () => {
115122 await cleanupBranch(repoDir, branch);
116123 });
117124
125+ test("initializes bun dependencies in worktree", async () => {
126+ const branch = `mc-sub-init-${Date.now()}`;
127+ const wtPath = join(
128+ tmpdir(),
129+ `mc-wt-test-${Date.now()}-${Math.random().toString(36).slice(2)}`,
130+ );
131+ extraDirs.push(wtPath);
132+
133+ writeFileSync(join(repoDir, "package.json"), "{}\n");
134+ writeFileSync(join(repoDir, "bun.lock"), "lock\n");
135+ mkdirSync(join(repoDir, "node_modules", "bun-types"), { recursive: true });
136+ writeFileSync(
137+ join(repoDir, "node_modules", "bun-types", "index.d.ts"),
138+ "\n",
139+ );
140+
141+ await createWorktree(repoDir, branch, wtPath);
142+ await initializeWorktree(repoDir, wtPath);
143+
144+ expect(await Bun.file(join(wtPath, "bun.lock")).text()).toBe("lock\n");
145+ expect(realpathSync(join(wtPath, "node_modules"))).toBe(
146+ realpathSync(join(repoDir, "node_modules")),
147+ );
148+ expect(lstatSync(join(wtPath, "node_modules")).isSymbolicLink()).toBe(true);
149+
150+ await removeWorktree(repoDir, wtPath);
151+ await cleanupBranch(repoDir, branch);
152+ });
153+
118154 test("creates a worktree and merges successfully", async () => {
119155 const branch = `mc-sub-1-${Date.now()}`;
120156 const wtPath = join(