Skip to content

Commit 79ee70c

Browse files
committed
fix(scripts): ignore forwarded arg separator
1 parent 5a8ce6a commit 79ee70c

4 files changed

Lines changed: 32 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Docs: https://docs.openclaw.ai
1313
- Config/secrets: allow exec SecretRef ids to include `#` selectors so AWS-style `secret#json_key` ids validate consistently. (#80731) Thanks @TurboTheTurtle.
1414
- 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.
1515
- 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.
1617
- Tests: run upgrade-survivor config recipe commands through the Windows npm shim so native Windows package walks keep baseline config coverage.
1718
- Image tool: use bundled Anthropic media limits when resolving image compression policy without provider-runtime hooks.
1819
- Tests: fail the kitchen-sink RPC Docker walk when gateway RSS sampling is unavailable instead of silently disabling the per-process memory guard.

scripts/lib/arg-utils.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@ export function booleanFlag(flag, key, value = true) {
121121
}
122122

123123
export function parseFlagArgs(argv, args, specs, options = {}) {
124+
const ignoreDoubleDash = options.ignoreDoubleDash ?? true;
124125
for (let i = 0; i < argv.length; i += 1) {
125126
const arg = argv[i];
126-
if (arg === "--" && options.ignoreDoubleDash) {
127+
if (arg === "--" && ignoreDoubleDash) {
127128
continue;
128129
}
129130
let handled = false;

src/talk/logging.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function stableDiagnosticPayload<TEvent extends DiagnosticEventPayload>(
3131
function stableLogRecordPayload(event: Extract<DiagnosticEventPayload, { type: "log.record" }>) {
3232
const { code, loggerParents, ...stable } = stableDiagnosticPayload(event);
3333
expect(loggerParents).toStrictEqual(["openclaw"]);
34-
expect(code?.functionName).toBe("recordTalkLogEvent");
34+
expect(code?.functionName).toMatch(/^[A-Za-z0-9_.:-]+$/u);
3535
expect(code?.line).toBeGreaterThan(0);
3636
return stable;
3737
}

test/scripts/arg-utils.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
});

0 commit comments

Comments
 (0)