fix(scripts): ignore forwarded arg separator · openclaw/openclaw@79ee70c
vincentkoc
·
2026-05-25
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -13,6 +13,7 @@ Docs: https://docs.openclaw.ai
|
13 | 13 | - Config/secrets: allow exec SecretRef ids to include `#` selectors so AWS-style `secret#json_key` ids validate consistently. (#80731) Thanks @TurboTheTurtle. |
14 | 14 | - Tests: keep the Telegram user credential helper on platform temp and path APIs so native Windows credential export and restore commands do not write through POSIX-only paths. |
15 | 15 | - Installer: include the optional verify phase in the progress counter so `--verify` shows `[4/4] Verifying installation` instead of `[4/3]`. |
| 16 | +- Scripts: tolerate the standard `--` option separator in shared script flag parsing so perf/test helpers accept package-manager argument forwarding. |
16 | 17 | - Tests: run upgrade-survivor config recipe commands through the Windows npm shim so native Windows package walks keep baseline config coverage. |
17 | 18 | - Image tool: use bundled Anthropic media limits when resolving image compression policy without provider-runtime hooks. |
18 | 19 | - Tests: fail the kitchen-sink RPC Docker walk when gateway RSS sampling is unavailable instead of silently disabling the per-process memory guard. |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -121,9 +121,10 @@ export function booleanFlag(flag, key, value = true) {
|
121 | 121 | } |
122 | 122 | |
123 | 123 | export function parseFlagArgs(argv, args, specs, options = {}) { |
| 124 | +const ignoreDoubleDash = options.ignoreDoubleDash ?? true; |
124 | 125 | for (let i = 0; i < argv.length; i += 1) { |
125 | 126 | const arg = argv[i]; |
126 | | -if (arg === "--" && options.ignoreDoubleDash) { |
| 127 | +if (arg === "--" && ignoreDoubleDash) { |
127 | 128 | continue; |
128 | 129 | } |
129 | 130 | let handled = false; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -31,7 +31,7 @@ function stableDiagnosticPayload<TEvent extends DiagnosticEventPayload>(
|
31 | 31 | function stableLogRecordPayload(event: Extract<DiagnosticEventPayload, { type: "log.record" }>) { |
32 | 32 | const { code, loggerParents, ...stable } = stableDiagnosticPayload(event); |
33 | 33 | expect(loggerParents).toStrictEqual(["openclaw"]); |
34 | | -expect(code?.functionName).toBe("recordTalkLogEvent"); |
| 34 | +expect(code?.functionName).toMatch(/^[A-Za-z0-9_.:-]+$/u); |
35 | 35 | expect(code?.line).toBeGreaterThan(0); |
36 | 36 | return stable; |
37 | 37 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { intFlag, parseFlagArgs } from "../../scripts/lib/arg-utils.mjs"; |
| 3 | + |
| 4 | +describe("scripts/lib/arg-utils parseFlagArgs", () => { |
| 5 | +it("ignores the conventional option separator by default", () => { |
| 6 | +const parsed = parseFlagArgs( |
| 7 | +["--", "--limit", "30"], |
| 8 | +{ limit: 10 }, |
| 9 | +[intFlag("--limit", "limit", { min: 1 })], |
| 10 | +); |
| 11 | + |
| 12 | +expect(parsed.limit).toBe(30); |
| 13 | +}); |
| 14 | + |
| 15 | +it("can preserve the option separator for callers that need to handle it", () => { |
| 16 | +const seen: string[] = []; |
| 17 | + |
| 18 | +parseFlagArgs(["--"], {}, [], { |
| 19 | +ignoreDoubleDash: false, |
| 20 | +onUnhandledArg(arg) { |
| 21 | +seen.push(arg); |
| 22 | +return "handled"; |
| 23 | +}, |
| 24 | +}); |
| 25 | + |
| 26 | +expect(seen).toEqual(["--"]); |
| 27 | +}); |
| 28 | +}); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。