fix: optimize routed CLI path (#1195) (thanks @gumadeiras)

This commit is contained in:
Peter Steinberger
2026-01-18 23:28:09 +00:00
parent fac0110e49
commit d5c8172197
9 changed files with 153 additions and 16 deletions

View File

@@ -1,5 +1,8 @@
import type { Command } from "commander";
import { defaultRuntime } from "../../runtime.js";
import { emitCliBanner } from "../banner.js";
import { getCommandPath, hasHelpOrVersion, isReadOnlyCommand } from "../argv.js";
import { ensureConfigReady } from "./config-guard.js";
function setProcessTitleForCommand(actionCommand: Command) {
let current: Command = actionCommand;
@@ -15,5 +18,11 @@ export function registerPreActionHooks(program: Command, programVersion: string)
program.hook("preAction", async (_thisCommand, actionCommand) => {
setProcessTitleForCommand(actionCommand);
emitCliBanner(programVersion);
const argv = process.argv;
if (hasHelpOrVersion(argv)) return;
const [primary] = getCommandPath(argv, 1);
if (primary === "doctor") return;
const migrateState = !isReadOnlyCommand(argv);
await ensureConfigReady({ runtime: defaultRuntime, migrateState });
});
}