Skip to content

Commit 4bc4ac3

Browse files
committed
fix: preserve root version alias for gateway binary rewrite
1 parent f7b6e31 commit 4bc4ac3

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/cli/run-main.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ describe("rewriteLegacyGatewayBinaryArgv", () => {
100100
expect(rewriteLegacyGatewayBinaryArgv(withLogLevel)).toBe(withLogLevel);
101101
});
102102

103+
it("keeps root version alias untouched for gateway binaries", () => {
104+
const rootAlias = ["node", "/usr/local/bin/openclaw-gateway", "-v"];
105+
expect(rewriteLegacyGatewayBinaryArgv(rootAlias)).toBe(rootAlias);
106+
107+
const withLogLevel = ["node", "/usr/local/bin/openclaw-gateway", "--log-level", "debug", "-v"];
108+
expect(rewriteLegacyGatewayBinaryArgv(withLogLevel)).toBe(withLogLevel);
109+
});
110+
103111
it("injects gateway after known root flags for normal gateway command paths", () => {
104112
expect(
105113
rewriteLegacyGatewayBinaryArgv([

src/cli/run-main.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ function isLegacyGatewayBinary(entryPath: string | undefined): boolean {
4040

4141
const ROOT_BOOLEAN_FLAGS = new Set(["--dev", "--no-color"]);
4242
const ROOT_VALUE_FLAGS = new Set(["--profile", "--log-level"]);
43+
const LEGACY_GATEWAY_PASSTHROUGH_TOKENS = new Set([
44+
"gateway",
45+
"update",
46+
"--update",
47+
"-h",
48+
"--help",
49+
"-v",
50+
"-V",
51+
"--version",
52+
]);
4353

4454
function resolveLegacyGatewayCommandToken(argv: string[]): {
4555
commandToken: string | undefined;
@@ -74,7 +84,7 @@ export function rewriteLegacyGatewayBinaryArgv(argv: string[]): string[] {
7484
return argv;
7585
}
7686
const { commandToken, commandIndex } = resolveLegacyGatewayCommandToken(argv);
77-
if (commandToken === "gateway" || commandToken === "update" || commandToken === "--update") {
87+
if (commandToken && LEGACY_GATEWAY_PASSTHROUGH_TOKENS.has(commandToken)) {
7888
return argv;
7989
}
8090
const next = [...argv];

0 commit comments

Comments
 (0)