From 35acf97c04a3050305e496ff1d71ff484b18fce3 Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Mon, 26 Feb 2024 09:42:36 -0700 Subject: [PATCH] fix: dont assume plugin-help is installed --- src/main.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main.ts b/src/main.ts index e4c6ce519..a136d5b55 100644 --- a/src/main.ts +++ b/src/main.ts @@ -38,6 +38,12 @@ export async function run(argv?: string[], options?: Interfaces.LoadOptions): Pr Performance.debug() } + const showHelp = async (argv: string[]) => { + const Help = await loadHelpClass(config) + const help = new Help(config, config.pjson.oclif.helpOptions ?? config.pjson.helpOptions) + await help.showHelp(argv) + } + debug(`process.execPath: ${process.execPath}`) debug(`process.execArgv: ${process.execArgv}`) debug('process.argv: %O', process.argv) @@ -63,9 +69,7 @@ export async function run(argv?: string[], options?: Interfaces.LoadOptions): Pr // display help version if applicable if (helpAddition(argv, config)) { - const Help = await loadHelpClass(config) - const help = new Help(config, config.pjson.oclif.helpOptions ?? config.pjson.helpOptions) - await help.showHelp(argv) + await showHelp(argv) await collectPerf() return } @@ -74,7 +78,12 @@ export async function run(argv?: string[], options?: Interfaces.LoadOptions): Pr const cmd = config.findCommand(id) if (!cmd) { const topic = config.flexibleTaxonomy ? null : config.findTopic(id) - if (topic) return config.runCommand('help', [id]) + if (topic) { + await showHelp([id]) + await collectPerf() + return + } + if (config.pjson.oclif.default) { id = config.pjson.oclif.default argvSlice = argv