|
7 | 7 |
|
8 | 8 | import { Topics } from "@coder-studio/core"; |
9 | 9 | import chokidar, { type FSWatcher } from "chokidar"; |
10 | | -import { mkdtemp, rm } from "fs/promises"; |
| 10 | +import { mkdtemp, rm, writeFile } from "fs/promises"; |
11 | 11 | import { tmpdir } from "os"; |
12 | 12 | import { join } from "path"; |
13 | 13 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
@@ -93,6 +93,22 @@ describe("WorkspaceWatcher", () => { |
93 | 93 | expect(ignored?.(join(testDir, "src/index.ts"))).toBe(false); |
94 | 94 | }); |
95 | 95 |
|
| 96 | + it("continues to respect .gitignore entries after tree visibility was relaxed", async () => { |
| 97 | + await writeFile(join(testDir, ".gitignore"), "dist/\n*.log\n"); |
| 98 | + |
| 99 | + new WorkspaceWatcher("test-workspace-id", testDir, broadcaster); |
| 100 | + |
| 101 | + expect(watchSpy).toHaveBeenCalledTimes(1); |
| 102 | + const options = watchSpy.mock.calls[0]?.[1]; |
| 103 | + const ignored = options?.ignored; |
| 104 | + |
| 105 | + expect(typeof ignored).toBe("function"); |
| 106 | + expect(ignored?.(join(testDir, "dist", "bundle.js"))).toBe(true); |
| 107 | + expect(ignored?.(join(testDir, "debug.log"))).toBe(true); |
| 108 | + expect(ignored?.(join(testDir, ".git", "index"))).toBe(false); |
| 109 | + expect(ignored?.(join(testDir, "src", "index.ts"))).toBe(false); |
| 110 | + }); |
| 111 | + |
96 | 112 | it("broadcasts fs.dirty after git metadata events settle", async () => { |
97 | 113 | vi.useFakeTimers(); |
98 | 114 | new WorkspaceWatcher("test-workspace-id", testDir, broadcaster); |
|
0 commit comments