mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 14:00:43 +00:00
fix(cli): keep update completion refresh lightweight
This commit is contained in:
@@ -106,4 +106,35 @@ describe("completion-cli write-state", () => {
|
||||
await fs.rm(stateDir, { recursive: true, force: true });
|
||||
await fs.rm(homeDir, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it("can skip plugin command registration for update-triggered cache writes", async () => {
|
||||
const [{ COMPLETION_SKIP_PLUGIN_COMMANDS_ENV }, { registerCompletionCli }] = await Promise.all([
|
||||
import("./completion-runtime.js"),
|
||||
import("./completion-cli.js"),
|
||||
]);
|
||||
const stateDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-completion-state-"));
|
||||
const homeDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-completion-home-"));
|
||||
|
||||
process.env.OPENCLAW_STATE_DIR = stateDir;
|
||||
process.env.HOME = homeDir;
|
||||
process.env[COMPLETION_SKIP_PLUGIN_COMMANDS_ENV] = "1";
|
||||
|
||||
try {
|
||||
const program = new Command();
|
||||
program.name("openclaw");
|
||||
registerCompletionCli(program);
|
||||
|
||||
await program.parseAsync(["completion", "--write-state"], { from: "user" });
|
||||
|
||||
expect(registerSubCliByNameMock).toHaveBeenCalledWith(program, "qa");
|
||||
expect(registerPluginCliCommandsFromValidatedConfigMock).not.toHaveBeenCalled();
|
||||
expect(await fs.readdir(path.join(stateDir, "completions"))).toEqual(
|
||||
expect.arrayContaining(["openclaw.bash", "openclaw.fish", "openclaw.ps1", "openclaw.zsh"]),
|
||||
);
|
||||
} finally {
|
||||
delete process.env[COMPLETION_SKIP_PLUGIN_COMMANDS_ENV];
|
||||
await fs.rm(stateDir, { recursive: true, force: true });
|
||||
await fs.rm(homeDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user