fix(qa): reject duplicate report artifacts · openclaw/openclaw@d51582a
vincentkoc
·
2026-06-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -19,23 +19,31 @@ export function parseReportCliArgs(argv) {
|
19 | 19 | jsonPath: null, |
20 | 20 | markdownPath: null, |
21 | 21 | }; |
| 22 | +const seen = new Set(); |
| 23 | +const setOnce = (flag, key, value) => { |
| 24 | +if (seen.has(flag)) { |
| 25 | +throw new Error(`${flag} was provided more than once.`); |
| 26 | +} |
| 27 | +seen.add(flag); |
| 28 | +options[key] = value; |
| 29 | +}; |
22 | 30 | for (let index = 0; index < argv.length; index += 1) { |
23 | 31 | const arg = argv[index]; |
24 | 32 | if (arg === "--") { |
25 | 33 | continue; |
26 | 34 | } |
27 | 35 | if (arg === "--root") { |
28 | | -options.rootDir = readReportOptionValue(argv, index, arg); |
| 36 | +setOnce(arg, "rootDir", readReportOptionValue(argv, index, arg)); |
29 | 37 | index += 1; |
30 | 38 | continue; |
31 | 39 | } |
32 | 40 | if (arg === "--json") { |
33 | | -options.jsonPath = readReportOptionValue(argv, index, arg); |
| 41 | +setOnce(arg, "jsonPath", readReportOptionValue(argv, index, arg)); |
34 | 42 | index += 1; |
35 | 43 | continue; |
36 | 44 | } |
37 | 45 | if (arg === "--markdown") { |
38 | | -options.markdownPath = readReportOptionValue(argv, index, arg); |
| 46 | +setOnce(arg, "markdownPath", readReportOptionValue(argv, index, arg)); |
39 | 47 | index += 1; |
40 | 48 | continue; |
41 | 49 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -34,4 +34,16 @@ describe("report-cli-helpers", () => {
|
34 | 34 | "Expected --markdown <value>.", |
35 | 35 | ); |
36 | 36 | }); |
| 37 | + |
| 38 | +it("rejects duplicate report artifact options", () => { |
| 39 | +expect(() => parseReportCliArgs(["--root", "/repo-a", "--root", "/repo-b"])).toThrow( |
| 40 | +"--root was provided more than once.", |
| 41 | +); |
| 42 | +expect(() => parseReportCliArgs(["--json", "first.json", "--json", "second.json"])).toThrow( |
| 43 | +"--json was provided more than once.", |
| 44 | +); |
| 45 | +expect(() => |
| 46 | +parseReportCliArgs(["--markdown", "first.md", "--markdown", "second.md"]), |
| 47 | +).toThrow("--markdown was provided more than once."); |
| 48 | +}); |
37 | 49 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。