mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 00:41:36 +00:00
fix(update): harden root selection
This commit is contained in:
30
src/cli/run-main.test.ts
Normal file
30
src/cli/run-main.test.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { rewriteUpdateFlagArgv } from "./run-main.js";
|
||||
|
||||
describe("rewriteUpdateFlagArgv", () => {
|
||||
it("leaves argv unchanged when --update is absent", () => {
|
||||
const argv = ["node", "entry.js", "status"];
|
||||
expect(rewriteUpdateFlagArgv(argv)).toBe(argv);
|
||||
});
|
||||
|
||||
it("rewrites --update into the update command", () => {
|
||||
expect(rewriteUpdateFlagArgv(["node", "entry.js", "--update"])).toEqual([
|
||||
"node",
|
||||
"entry.js",
|
||||
"update",
|
||||
]);
|
||||
});
|
||||
|
||||
it("preserves global flags that appear before --update", () => {
|
||||
expect(
|
||||
rewriteUpdateFlagArgv(["node", "entry.js", "--profile", "p", "--update"]),
|
||||
).toEqual(["node", "entry.js", "--profile", "p", "update"]);
|
||||
});
|
||||
|
||||
it("keeps update options after the rewritten command", () => {
|
||||
expect(
|
||||
rewriteUpdateFlagArgv(["node", "entry.js", "--update", "--json"]),
|
||||
).toEqual(["node", "entry.js", "update", "--json"]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user