Skip to content

Commit 980b9cd

Browse files
committed
Pin dash-prefixed cwd tokens in CLI flag tests
The previous case passed an absolute path whose last segment was -my-dir, so reverting isFlagToken to startsWith("-") would still pass CI while breaking corbits --cwd -my-dir. Bind the argv token itself and assert cwd is resolve("-my-dir"). Also cover omitted --cwd/--config/--profile.
1 parent 8fb27d3 commit 980b9cd

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

src/config.test.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, test, expect } from "bun:test";
22
import { mkdtemp, mkdir, writeFile, rm } from "node:fs/promises";
33
import { tmpdir } from "node:os";
4-
import { join } from "node:path";
4+
import { join, resolve } from "node:path";
55

66
import {
77
buildBifrostSource,
@@ -803,22 +803,23 @@ describe("loadConfig", () => {
803803
await expect(loadConfig(["--model"], { globalSettingsPath: NO_SETTINGS })).rejects.toThrow(
804804
"--model requires a value",
805805
);
806+
await expect(loadConfig(["--cwd"], { globalSettingsPath: NO_SETTINGS })).rejects.toThrow(
807+
"--cwd requires a value",
808+
);
809+
await expect(loadConfig(["--config"], { globalSettingsPath: NO_SETTINGS })).rejects.toThrow(
810+
"--config requires a value",
811+
);
812+
await expect(loadConfig(["--profile"], { globalSettingsPath: NO_SETTINGS })).rejects.toThrow(
813+
"--profile requires a value",
814+
);
806815
});
807816

808817
test("value flags accept a POSIX path that starts with a single dash", async () => {
809-
const parent = await emptyCwd();
810-
const dashedCwd = join(parent, "-my-dir");
811-
await mkdir(dashedCwd);
812-
try {
813-
const globalPath = await writeGlobalSettings(dashedCwd);
814-
const config = await loadConfig(["--cwd", dashedCwd, "do something"], {
815-
globalSettingsPath: globalPath,
816-
});
817-
assertConfigured(config);
818-
expect(config.cwd).toBe(dashedCwd);
819-
} finally {
820-
await rm(parent, { recursive: true, force: true });
821-
}
818+
const config = await loadConfig(["--cwd", "-my-dir", "do something"], {
819+
allowUnconfigured: true,
820+
globalSettingsPath: NO_SETTINGS,
821+
});
822+
expect(config.cwd).toBe(resolve("-my-dir"));
822823
});
823824

824825
test("rejects unknown flags", async () => {

0 commit comments

Comments
 (0)