


























@@ -106,4 +106,35 @@ describe("completion-cli write-state", () => {
106106await fs.rm(stateDir, { recursive: true, force: true });
107107await fs.rm(homeDir, { recursive: true, force: true });
108108});
109+110+it("can skip plugin command registration for update-triggered cache writes", async () => {
111+const [{ COMPLETION_SKIP_PLUGIN_COMMANDS_ENV }, { registerCompletionCli }] = await Promise.all([
112+import("./completion-runtime.js"),
113+import("./completion-cli.js"),
114+]);
115+const stateDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-completion-state-"));
116+const homeDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-completion-home-"));
117+118+process.env.OPENCLAW_STATE_DIR = stateDir;
119+process.env.HOME = homeDir;
120+process.env[COMPLETION_SKIP_PLUGIN_COMMANDS_ENV] = "1";
121+122+try {
123+const program = new Command();
124+program.name("openclaw");
125+registerCompletionCli(program);
126+127+await program.parseAsync(["completion", "--write-state"], { from: "user" });
128+129+expect(registerSubCliByNameMock).toHaveBeenCalledWith(program, "qa");
130+expect(registerPluginCliCommandsFromValidatedConfigMock).not.toHaveBeenCalled();
131+expect(await fs.readdir(path.join(stateDir, "completions"))).toEqual(
132+expect.arrayContaining(["openclaw.bash", "openclaw.fish", "openclaw.ps1", "openclaw.zsh"]),
133+);
134+} finally {
135+delete process.env[COMPLETION_SKIP_PLUGIN_COMMANDS_ENV];
136+await fs.rm(stateDir, { recursive: true, force: true });
137+await fs.rm(homeDir, { recursive: true, force: true });
138+}
139+});
109140});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。