Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/loopover-miner/lib/deny-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ export function parseDenyCheckArgs(args) {
}
if (token === "--tool" || token === "--name") {
const tool = args[++index];
if (!tool) return { error: "Missing value for --tool." };
if (!tool || tool.startsWith("-")) return { error: "Missing value for --tool." };
options.tool = tool;
continue;
}
if (token === "--input") {
const parsed = parseToolInput(args[++index]);
const raw = args[++index];
if (!raw || raw.startsWith("-")) return { error: "Missing value for --input." };
const parsed = parseToolInput(raw);
if ("error" in parsed) return { error: parsed.error };
options.input = parsed.value;
continue;
Expand Down
12 changes: 12 additions & 0 deletions test/unit/miner-cli-deny-check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ describe("loopover-miner hooks check command", () => {
});
});

it("parseDenyCheckArgs rejects a flag consumed as another flag's value (#5833)", () => {
// --tool/--input must not swallow an adjacent flag as their value; each reports the specific
// "Missing value" error rather than falling through to the generic usage string.
expect(parseDenyCheckArgs(["--tool"])).toEqual({ error: "Missing value for --tool." });
expect(parseDenyCheckArgs(["--tool", "--input", "{}"])).toEqual({ error: "Missing value for --tool." });
expect(parseDenyCheckArgs(["--name", "--json"])).toEqual({ error: "Missing value for --tool." });
expect(parseDenyCheckArgs(["--tool", "Write", "--input"])).toEqual({ error: "Missing value for --input." });
expect(parseDenyCheckArgs(["--tool", "Write", "--input", "--json"])).toEqual({
error: "Missing value for --input.",
});
});

it("runDenyCheck exits 1 when a built-in rule blocks the call", () => {
const error = vi.spyOn(console, "error").mockImplementation(() => undefined);
expect(
Expand Down