mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix(tooling): reject malformed topology limits
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
createPluginSdkScope,
|
||||
} from "./lib/ts-topology/scope.js";
|
||||
import type { TopologyReportName, TopologyScope } from "./lib/ts-topology/types.js";
|
||||
import { parsePositiveInt } from "./lib/numeric-options.mjs";
|
||||
|
||||
const VALID_REPORTS = new Set<TopologyReportName>([
|
||||
"public-surface-usage",
|
||||
@@ -86,7 +87,7 @@ function parseArgs(argv: string[]): CliOptions {
|
||||
options.report = (value as TopologyReportName | undefined) ?? options.report;
|
||||
break;
|
||||
case "--limit":
|
||||
options.limit = Math.max(1, Number.parseInt(value ?? "25", 10));
|
||||
options.limit = parsePositiveInt(value, "--limit");
|
||||
break;
|
||||
case "--repo-root":
|
||||
options.repoRoot = path.resolve(value ?? options.repoRoot);
|
||||
|
||||
@@ -198,6 +198,15 @@ describe("ts-topology", () => {
|
||||
`);
|
||||
});
|
||||
|
||||
it("rejects malformed CLI limits", async () => {
|
||||
const captured = createCapturedIo();
|
||||
const exitCode = await main(["--limit=abc"], captured.io);
|
||||
|
||||
expect(exitCode).toBe(1);
|
||||
expect(captured.readStderr()).toContain("--limit must be a positive integer");
|
||||
expect(captured.readStdout()).toBe("");
|
||||
});
|
||||
|
||||
it("throws a clear error for invalid text report names", () => {
|
||||
expect(() =>
|
||||
renderTextReport(
|
||||
|
||||
Reference in New Issue
Block a user