fix(scripts): reject short flag version values · openclaw/openclaw@a0f28bd
vincentkoc
·
2026-06-22
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -25,7 +25,7 @@ export function budgetFloatFlag(flag, key) {
|
25 | 25 | return null; |
26 | 26 | } |
27 | 27 | const value = argv[index + 1]; |
28 | | -if (!value || value.startsWith("--")) { |
| 28 | +if (!value || value.startsWith("-")) { |
29 | 29 | throw new Error(`${flag} requires a value`); |
30 | 30 | } |
31 | 31 | return { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -93,7 +93,7 @@ export function parseVersionSyncArgs(argv: string[]): VersionSyncCliOptions {
|
93 | 93 | |
94 | 94 | function readOptionValue(argv: string[], index: number, flag: string): string { |
95 | 95 | const value = argv[index + 1]; |
96 | | -if (!value || value.startsWith("--")) { |
| 96 | +if (!value || value.startsWith("-")) { |
97 | 97 | throw new Error(`Missing value for ${flag}.`); |
98 | 98 | } |
99 | 99 | return value; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -33,6 +33,18 @@ describe("resolveAndroidVersion", () => {
|
33 | 33 | |
34 | 34 | expect(result.status).toBe(1); |
35 | 35 | expect(result.stderr).toBe("Missing value for --field.\n"); |
| 36 | + |
| 37 | +const shortFlagResult = spawnSync( |
| 38 | +process.execPath, |
| 39 | +["--import", "tsx", "scripts/android-version.ts", "--field", "-h"], |
| 40 | +{ |
| 41 | +cwd: process.cwd(), |
| 42 | +encoding: "utf8", |
| 43 | +}, |
| 44 | +); |
| 45 | + |
| 46 | +expect(shortFlagResult.status).toBe(1); |
| 47 | +expect(shortFlagResult.stderr).toBe("Missing value for --field.\n"); |
36 | 48 | }); |
37 | 49 | |
38 | 50 | it("prints selected fields from the CLI", () => { |
@@ -74,6 +86,18 @@ describe("resolveAndroidVersion", () => {
|
74 | 86 | |
75 | 87 | expect(result.status).toBe(1); |
76 | 88 | expect(result.stderr).toBe("Missing value for --root.\n"); |
| 89 | + |
| 90 | +const shortFlagResult = spawnSync( |
| 91 | +process.execPath, |
| 92 | +["--import", "tsx", "scripts/android-sync-versioning.ts", "--root", "-h"], |
| 93 | +{ |
| 94 | +cwd: process.cwd(), |
| 95 | +encoding: "utf8", |
| 96 | +}, |
| 97 | +); |
| 98 | + |
| 99 | +expect(shortFlagResult.status).toBe(1); |
| 100 | +expect(shortFlagResult.stderr).toBe("Missing value for --root.\n"); |
77 | 101 | }); |
78 | 102 | |
79 | 103 | it("parses pinned release versions and Android version codes", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -29,6 +29,18 @@ describe("resolveIosVersion", () => {
|
29 | 29 | |
30 | 30 | expect(result.status).toBe(1); |
31 | 31 | expect(result.stderr).toBe("Missing value for --field.\n"); |
| 32 | + |
| 33 | +const shortFlagResult = spawnSync( |
| 34 | +process.execPath, |
| 35 | +["--import", "tsx", "scripts/ios-version.ts", "--field", "-h"], |
| 36 | +{ |
| 37 | +cwd: process.cwd(), |
| 38 | +encoding: "utf8", |
| 39 | +}, |
| 40 | +); |
| 41 | + |
| 42 | +expect(shortFlagResult.status).toBe(1); |
| 43 | +expect(shortFlagResult.stderr).toBe("Missing value for --field.\n"); |
32 | 44 | }); |
33 | 45 | |
34 | 46 | it("prints selected fields from the CLI", () => { |
@@ -70,6 +82,18 @@ describe("resolveIosVersion", () => {
|
70 | 82 | |
71 | 83 | expect(result.status).toBe(1); |
72 | 84 | expect(result.stderr).toBe("Missing value for --root.\n"); |
| 85 | + |
| 86 | +const shortFlagResult = spawnSync( |
| 87 | +process.execPath, |
| 88 | +["--import", "tsx", "scripts/ios-sync-versioning.ts", "--root", "-h"], |
| 89 | +{ |
| 90 | +cwd: process.cwd(), |
| 91 | +encoding: "utf8", |
| 92 | +}, |
| 93 | +); |
| 94 | + |
| 95 | +expect(shortFlagResult.status).toBe(1); |
| 96 | +expect(shortFlagResult.stderr).toBe("Missing value for --root.\n"); |
73 | 97 | }); |
74 | 98 | |
75 | 99 | it("parses pinned release versions and derives Apple marketing fields", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -79,6 +79,12 @@ describe("test perf budget script", () => {
|
79 | 79 | expect(() => testing.parseArgs(["--max-wall-ms", "--baseline-wall-ms", "1000"], {})).toThrow( |
80 | 80 | "--max-wall-ms requires a value", |
81 | 81 | ); |
| 82 | +expect(() => testing.parseArgs(["--max-wall-ms", "-h"], {})).toThrow( |
| 83 | +"--max-wall-ms requires a value", |
| 84 | +); |
| 85 | +expect(() => testing.parseArgs(["--max-regression-pct", "-h"], {})).toThrow( |
| 86 | +"--max-regression-pct requires a value", |
| 87 | +); |
82 | 88 | }); |
83 | 89 | |
84 | 90 | it("requires timed file evidence in the Vitest JSON report", () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。