fix(init): respect --minimal flag for agent rule files (#26051)

## Summary
- Fixes `bun init --minimal` creating Cursor rules files and CLAUDE.md
when it shouldn't
- Adds regression test to verify `--minimal` only creates package.json
and tsconfig.json

## Test plan
- [x] Verify test fails with system bun (unfixed): `USE_SYSTEM_BUN=1 bun
test test/cli/init/init.test.ts -t "bun init --minimal"`
- [x] Verify test passes with debug build: `bun bd test
test/cli/init/init.test.ts -t "bun init --minimal"`
- [x] All existing init tests pass: `bun bd test
test/cli/init/init.test.ts`

Fixes #26050

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
robobun
2026-01-13 18:33:42 -08:00
committed by GitHub
parent fbd800551b
commit ab009fe00d
2 changed files with 33 additions and 1 deletions

View File

@@ -295,4 +295,34 @@ import path from "path";
expect(fs.existsSync(path.join(temp, "src/components"))).toBe(true);
expect(fs.existsSync(path.join(temp, "src/components/ui"))).toBe(true);
}, 30_000);
test("bun init --minimal only creates package.json and tsconfig.json", async () => {
// Regression test for https://github.com/oven-sh/bun/issues/26050
// --minimal should not create .cursor/, CLAUDE.md, .gitignore, or README.md
const temp = tempDirWithFiles("bun-init-minimal", {});
const { exited } = Bun.spawn({
cmd: [bunExe(), "init", "--minimal", "-y"],
cwd: temp,
stdio: ["ignore", "inherit", "inherit"],
env: {
...bunEnv,
// Simulate Cursor being installed via CURSOR_TRACE_ID env var
CURSOR_TRACE_ID: "test-trace-id",
},
});
expect(await exited).toBe(0);
// Should create package.json and tsconfig.json
expect(fs.existsSync(path.join(temp, "package.json"))).toBe(true);
expect(fs.existsSync(path.join(temp, "tsconfig.json"))).toBe(true);
// Should NOT create these extra files with --minimal
expect(fs.existsSync(path.join(temp, "index.ts"))).toBe(false);
expect(fs.existsSync(path.join(temp, ".gitignore"))).toBe(false);
expect(fs.existsSync(path.join(temp, "README.md"))).toBe(false);
expect(fs.existsSync(path.join(temp, "CLAUDE.md"))).toBe(false);
expect(fs.existsSync(path.join(temp, ".cursor"))).toBe(false);
});
});