mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-20 18:24:46 +00:00
fix(cli): keep plugin parent help lightweight
This commit is contained in:
@@ -65,14 +65,14 @@ async function registerSubCliWithPluginCommands(
|
||||
const invocation = resolveCliArgvInvocation(process.argv);
|
||||
const shouldRegisterPluginCommands =
|
||||
!invocation.hasHelpOrVersion &&
|
||||
(invocation.commandPath.length <= 1 ||
|
||||
resolveCliCommandPathPolicy(invocation.commandPath).loadPlugins !== "never");
|
||||
const { registerPluginCliCommandsFromValidatedConfig } = await import("../../plugins/cli.js");
|
||||
resolveCliCommandPathPolicy(invocation.commandPath).loadPlugins !== "never";
|
||||
if (pluginCliPosition === "before" && shouldRegisterPluginCommands) {
|
||||
const { registerPluginCliCommandsFromValidatedConfig } = await import("../../plugins/cli.js");
|
||||
await registerPluginCliCommandsFromValidatedConfig(program);
|
||||
}
|
||||
await registerSubCli();
|
||||
if (pluginCliPosition === "after" && shouldRegisterPluginCommands) {
|
||||
const { registerPluginCliCommandsFromValidatedConfig } = await import("../../plugins/cli.js");
|
||||
await registerPluginCliCommandsFromValidatedConfig(program);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,13 +253,13 @@ describe("registerSubCliCommands", () => {
|
||||
expect(registerPluginCliCommandsFromValidatedConfig).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps plugin CLI registrations available for the plugins command root", async () => {
|
||||
it("does not preload plugin CLI registrations for bare plugin parent help", async () => {
|
||||
process.argv = ["node", "openclaw", "plugins"];
|
||||
const program = new Command().name("openclaw");
|
||||
|
||||
await registerSubCliByName(program, "plugins");
|
||||
|
||||
expect(registerPluginsCli).toHaveBeenCalledTimes(1);
|
||||
expect(registerPluginCliCommandsFromValidatedConfig).toHaveBeenCalledTimes(1);
|
||||
expect(registerPluginCliCommandsFromValidatedConfig).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user