Compare commits

...

4 Commits

Author SHA1 Message Date
Claude Bot
ed687afccc test: use harness resource-management in outdir/outfile test
Replace tmpdirSync() with tempDir() and wrap Bun.spawn() with
"await using" to ensure proper cleanup of spawned process and
temporary directory.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 20:01:54 +00:00
RiskyMH
39b024bee3 test: add test for --outdir and --outfile mutual exclusion 2025-12-01 20:36:21 +11:00
RiskyMH
807fa27c5a Merge remote-tracking branch 'origin/main' into riskymh/bun-build-outdirfile 2025-12-01 16:50:54 +11:00
RiskyMH
c7e44aa91b don't allow --outfile at same time as --outdir in bun build 2025-07-29 10:30:30 +10:00
2 changed files with 20 additions and 0 deletions

View File

@@ -1144,6 +1144,10 @@ pub fn parse(allocator: std.mem.Allocator, ctx: Command.Context, comptime cmd: C
}
if (args.option("--outdir")) |outdir| {
if (args.option("--outfile")) |_| {
Output.errGeneric("cannot use both --outdir and --outfile", .{});
Global.exit(1);
}
if (outdir.len > 0) {
ctx.bundler_options.outdir = outdir;
}

View File

@@ -419,3 +419,19 @@ test("log case 2", async () => {
"
`);
});
test("cannot use both --outdir and --outfile", async () => {
using dir = tempDir("outdir-outfile-test", {
"input.js": 'console.log("Hello, world!");',
});
await using subprocess = Bun.spawn({
cmd: [bunExe(), "build", "--outdir=" + dir + "/out", "--outfile=" + dir + "/out.js", dir + "/input.js"],
env: bunEnv,
cwd: String(dir),
stderr: "pipe",
});
expect(await subprocess.stderr.text()).toContain("cannot use both --outdir and --outfile");
expect(await subprocess.exited).not.toBe(0);
});