mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-28 23:03:43 +00:00
fix(scripts): reject short flag report values
This commit is contained in:
@@ -7,7 +7,7 @@ import path from "node:path";
|
||||
*/
|
||||
function readReportOptionValue(argv, index, optionName) {
|
||||
const value = argv[index + 1];
|
||||
if (value === undefined || value === "" || value.startsWith("--")) {
|
||||
if (value === undefined || value === "" || value.startsWith("-")) {
|
||||
throw new Error(`Expected ${optionName} <value>.`);
|
||||
}
|
||||
return value;
|
||||
|
||||
@@ -23,10 +23,15 @@ describe("report-cli-helpers", () => {
|
||||
expect(() => parseReportCliArgs(["--root", "--json", "report.json"])).toThrow(
|
||||
"Expected --root <value>.",
|
||||
);
|
||||
expect(() => parseReportCliArgs(["--root", "-h"])).toThrow("Expected --root <value>.");
|
||||
expect(() => parseReportCliArgs(["--json"])).toThrow("Expected --json <value>.");
|
||||
expect(() => parseReportCliArgs(["--json", "--markdown", "report.md"])).toThrow(
|
||||
"Expected --json <value>.",
|
||||
);
|
||||
expect(() => parseReportCliArgs(["--json", "-h"])).toThrow("Expected --json <value>.");
|
||||
expect(() => parseReportCliArgs(["--markdown", ""])).toThrow("Expected --markdown <value>.");
|
||||
expect(() => parseReportCliArgs(["--markdown", "-h"])).toThrow(
|
||||
"Expected --markdown <value>.",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user