mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix(scripts): ignore forwarded arg separator
This commit is contained in:
@@ -13,6 +13,7 @@ Docs: https://docs.openclaw.ai
|
||||
- Config/secrets: allow exec SecretRef ids to include `#` selectors so AWS-style `secret#json_key` ids validate consistently. (#80731) Thanks @TurboTheTurtle.
|
||||
- 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.
|
||||
- Installer: include the optional verify phase in the progress counter so `--verify` shows `[4/4] Verifying installation` instead of `[4/3]`.
|
||||
- Scripts: tolerate the standard `--` option separator in shared script flag parsing so perf/test helpers accept package-manager argument forwarding.
|
||||
- Tests: run upgrade-survivor config recipe commands through the Windows npm shim so native Windows package walks keep baseline config coverage.
|
||||
- Image tool: use bundled Anthropic media limits when resolving image compression policy without provider-runtime hooks.
|
||||
- Tests: fail the kitchen-sink RPC Docker walk when gateway RSS sampling is unavailable instead of silently disabling the per-process memory guard.
|
||||
|
||||
@@ -121,9 +121,10 @@ export function booleanFlag(flag, key, value = true) {
|
||||
}
|
||||
|
||||
export function parseFlagArgs(argv, args, specs, options = {}) {
|
||||
const ignoreDoubleDash = options.ignoreDoubleDash ?? true;
|
||||
for (let i = 0; i < argv.length; i += 1) {
|
||||
const arg = argv[i];
|
||||
if (arg === "--" && options.ignoreDoubleDash) {
|
||||
if (arg === "--" && ignoreDoubleDash) {
|
||||
continue;
|
||||
}
|
||||
let handled = false;
|
||||
|
||||
@@ -31,7 +31,7 @@ function stableDiagnosticPayload<TEvent extends DiagnosticEventPayload>(
|
||||
function stableLogRecordPayload(event: Extract<DiagnosticEventPayload, { type: "log.record" }>) {
|
||||
const { code, loggerParents, ...stable } = stableDiagnosticPayload(event);
|
||||
expect(loggerParents).toStrictEqual(["openclaw"]);
|
||||
expect(code?.functionName).toBe("recordTalkLogEvent");
|
||||
expect(code?.functionName).toMatch(/^[A-Za-z0-9_.:-]+$/u);
|
||||
expect(code?.line).toBeGreaterThan(0);
|
||||
return stable;
|
||||
}
|
||||
|
||||
28
test/scripts/arg-utils.test.ts
Normal file
28
test/scripts/arg-utils.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { intFlag, parseFlagArgs } from "../../scripts/lib/arg-utils.mjs";
|
||||
|
||||
describe("scripts/lib/arg-utils parseFlagArgs", () => {
|
||||
it("ignores the conventional option separator by default", () => {
|
||||
const parsed = parseFlagArgs(
|
||||
["--", "--limit", "30"],
|
||||
{ limit: 10 },
|
||||
[intFlag("--limit", "limit", { min: 1 })],
|
||||
);
|
||||
|
||||
expect(parsed.limit).toBe(30);
|
||||
});
|
||||
|
||||
it("can preserve the option separator for callers that need to handle it", () => {
|
||||
const seen: string[] = [];
|
||||
|
||||
parseFlagArgs(["--"], {}, [], {
|
||||
ignoreDoubleDash: false,
|
||||
onUnhandledArg(arg) {
|
||||
seen.push(arg);
|
||||
return "handled";
|
||||
},
|
||||
});
|
||||
|
||||
expect(seen).toEqual(["--"]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user